Categories
Uncategorized

Blink Without Pause on the micro:bit

If you’ve ever used an Arduino there’s a good chance you started with the Blink sketch, which is a great introduction to programming a physical computing device where you can see the outcome in the form a blinking LED. As you learn more and things get complex, you discover that using the delay statement in your code is not ideal as it prevents the code from continually running, so you can’t properly capture input to your microcontroller. There’s more over at the Blink Without Delay tutorial on this topic.

I’ve been doing a lot with the micro:bit lately, and my quick searches gave no equivalent for Blink Without Delay so I created Blink Without Pause.

The tutorial starts with micro:bit code for Blink With Pause (which is really just Blink) and then Blink Without Pause so you can compare the two.

For a real-world example there are two more, Blink With Pause With Button and then Blink Without Pause With Button which should clearly illustrate the value of not using pause if your code needs to do other things.

Oh, if you’re wondering where the micro:bit is in the illustrations above… it’s not there! The diagrams show the Bit Board that Brown Dog Gadgets will be releasing this fall as part of a Kickstarter campaign. Follow on Twitter, Instagram, or Facebook to see some of the other projects we’ve been doing and find out when the campaign launches.

Categories
Uncategorized

Arduino – Random Colors

Colors

One of my PCOMP students wants to randomly select a set of RGB values from a predetermined list. It’s the sort of things where I know the concept is easy but the execution is a bit more difficult only because I’ve done it in other languages/environments, but not in an Arduino sketch.

The nice thing about programming is that once you know how to do something using one language, the concepts transfer over to other languages, and it becomes mostly a matter of figuring out the syntax and method to make it all work.

Here’s an example sketch that allows you to have a list (array) of RGB values and then randomly select one and return it, split the r, g, b into their own integer variables, and then print them to the serial monitor. (The final version will use analogWrite to control RGB LEDs.)

// RandomColor.ino

void setup() {
  Serial.begin(9600);
  randomSeed(analogRead(A0));
}

void loop() {
  char* rgb = returnColors();
  int r, g, b;
  if (sscanf(rgb, "%d,%d,%d", &r, &g, &b) == 3) {
    Serial.print(r);
    Serial.print(", ");
    Serial.print(g);
    Serial.print(", ");
    Serial.println(b);
  }
  delay(500);
}

char* returnColors() {
  char* myColors[6];
  myColors[0] = "128,0,0";
  myColors[1] = "0,128,0";
  myColors[2] = "0,0,128";
  myColors[3] = "255,0,0";
  myColors[4] = "0,255,0";
  myColors[5] = "0,0,255";
  int colorIndex = random(0,6);
  char* result = myColors[colorIndex];
  return (result);
}

Obviously the list can be much larger than just six elements, but this is example code to be expanded upon.

You can also grab this code from github.

Update: Royce has his own version you can check out. He suggests it should be more efficient because the textual RGB values are converted to binary at compile time rather than runtime.

Categories
Uncategorized

PCOMP – Assignment 3

Cameron

Alex

Katrina

Maks

Megan

Sadie

Stefanie

Sarah

Malcolm

Raven

Ali

Chance

We’re already half way through the semester and finished our third assignment for Electronics and Sculpture last week. Assignment 3 requires analog input and output for the project. (Assignment 1 is purely digital, and Assignment 2 requires analog input for control.) And yes, the class is called “Electronics and Sculpture” but it could just as easily be named “Arduino for Artists”.

Projects have varied from very interactive to installations to mostly sculptural with some electronics added in. I find that students do the best work when they can take what they are learning in class and combine it with their own practice, or what they are learning in other classes. The Digital Fabrication students definitely have an advantage here, and I wish all of the students had access to digital fabrication tools, though we just wouldn’t have time to cover it all in the 318 class. (That’s not to say the work of non-Digital Fabrication students is lacking in any way, and I’ve seen some great work using very simple material and tools. As always, art is a combination of things, including concepts, themes, ideas, technical skills and abilities, and more.)

We’re currently in the middle of the midterm project, and things are coming together quite well. Critique is in two weeks, and after that we launch right into the final project. (Since there isn’t an Arts+Tech Night this semester, we’ll probably just push the final critique onto the date that our final exam is scheduled for.)

Categories
Uncategorized

Physical Computing – Spring 2016

Mike's Light Sculpture

The Electronics and Sculpture class I taught this semester wrapped up a few weeks ago and my students showed their final projects at Arts+Tech Night in May. I’ve included a few photos in this post, but each student also posted their project online, so check below for more links.

Lionel's Brick

The class was structured around five projects in total, with three being smaller projects focusing on digital input/output, analog sensors controlling 2-3 digital things, and the third using analog input/output. The last two projects were larger, one being the mid-term project and the other being the final project, which was then shown to the public during Arts+Tech Night, and treated as an installation for the event.

Greg's Drumming Machine

The books we used for the course were Make: Electronics: Learning Through Discovery by Charles Platt and Programming Arduino Getting Started with Sketches by Simon Monk. I think the amount of reading was fairly minimal, but needed up front for a lot of the things we did later in the semester.

William's Ugly Box

Much of the first half of the semester was spent going through some of the basics of electrical circuits and getting up to speed with the Arduino, learning how to wire things up, write code, and use libraries. Some students had never written code before, while others had never really built physical things before. Some students were more versed in the digital arts while others were more skilled in creating sculptural things. Students who had access to the DCRL had an advantage due to the tools and equipment they had access to (and the fact that they studied with Frankie.)

Matt's Controller

As part of the class, each student had to post their work on a public web site. Some students had blogs or portfolio sites, and some created new sites. Here’s the list of students and their web sites:

Not every student managed to write up their project, which caused me much sadness, but many did a great job of documenting their work and process.

Alycia's Kiosk

I’ll be teaching Electronics and Sculpture 318 and 418 again in the fall, and it looks like 6 of my 318 students are returning for 418 (the advanced class) so I can’t wait to see what they come up with next time!

Categories
Uncategorized

Arts+Tech Night at UWM

Arts+Tech Night

I mentioned back in February that I’ve been teaching a Physical Computing class at UWM called “Electronics and Sculpture” this semester. So I’ve basically been showing students how to integrate microcontrollers into their artwork. (Arduino is the order of the day, though I’ve got one student exploring ATtiny85 chips.)

Students have been working on their final projects, using techniques they’ve learned all semester, and they’ll have their work on display for the public at Arts+Tech Night happening 6pm-9pm, Wednesday, May 18th, 2016. Come on down and check it out. Most of my students will be on the 4th floor in the center area. (Maybe your friends are already going!)

mike-light

(There is a web site for ATN but sadly, despite my best efforts, It has not been updated this time around.)