posts tagged with the keyword ‘arduino’

2016.12.08

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.

2016.06.05

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!

2016.05.16

Teensy LC BOB v1.3

Good News, Everyone! The new Teensy LC break-out board is ready! Yes, we’re now at version 1.3 of the Teensy LC BOB.

Preview

I’ve made a few changes since version 1.2. I moved the traces from the top to the bottom (how did I miss that!?) and I added an extra ground line so that you can connect a bunch of screw terminals to the ground row even if you don’t solder in header pins at the end of the board and only do the sides. (This also comes in handy if using the Teensy Audio Adaptor Board.)

I’ve also lengthened the board a bit, and added a fifth hole, and here’s why…

Installed

For a recent project I discovered that the USB cable was able to rip the USB connector right off the Teensy if hit, twisted, or yanked in the wrong direction. The fifth hole is for adding a piece (wood? plastic?) by screwing it into the bottom and then looping a zip tie around the USB cable for strain relief.

USB mock-up

I scanned in a Micro USB cable and placed it over an image of the board to figure out spacing. It should work. I may end up 3D modeling the piece that holds the USB cable in place.

As I use the boards more I may find other improvements along the way. Also, I’m now able to load in custom images and graphics onto the PCB, so I’m already scheming for my next OSH Park project.

2016.05.15

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.)

2016.04.27

Traffic Lights

I recently repaired the traffic and walk signals at BBCM. The system had been running on a PLC (Programmable Logic Controller) which failed, and rather than find the proprietary programming cable and find and install the PLC Windows software, I decided to just put an Arduino and relay control board in place.

Arduino and Relay Board

I had a Teensy++ 2.0 I had pulled from another exhibit during an upgrade, and an 8 channel relay board on hand. These relay boards come in different configurations from 1, 2, 4, 8, and even 16 relays. Since I really only needed 5 relays (and 5 pins) I could have used an ATtiny85, but I had the Teensy++ 2.0 readily available. The wiring is all done using female to female jumper wires.

Traffic Controller

I mounted everything to a piece of scrap MDF and added mounting holes to that, with the idea that we’d screw the whole thing directly into the wall. The relay board has mounting holes, but the Teensy does not. That’s probably my one complaint about the Teensy boards, is that mounting them isn’t always easy. My Teensy BOB has mounting holes, but for mounting this Teensy++ 2.0 I just used some 3M™ VHB™ tape. (The “VHB” stands for “Very High Bond”). And yes, there are a few 3D printed parts on there. At some point I should make a 3D printed holder/mount for a Teensy++ 2.0

Labels

I try to label things clearly. If I look at this thing in 6 months, or 2 years, or someone else has to look at it, I want it to be somewhat apparent what is what, so there’s not a lot of guesswork as to what is going on. I included a label with the name of the Arduino sketch, and I always like to label power supplies. Sometimes we use 5 volts, and sometimes 12 volts, and they typically have tiny hard to read type printed on the side of the power supply that you can’t see when it’s plugged in.

The one thing I should start to add to the labels is the URL of the wiki page where the thing is documented. (Next time I’ll do this.)

Controller Mounted

Here’s the controller mounted. It’s not pretty. We ended up re-using the mount that the PLC was in, rather than screwing it right into the wall. In my defense, we did this repair on the floor during open hours, and it’s mounted high on a wall behind a TV. Does it work? Yes… Is it awesome, no… but again, it totally works.

The wiring for the lights was all 12 VDC, not 110 VAC, so those thin gauge wires are fine. Also, they were labeled, which was handy. (Thanks previous person who worked on this and labeled things!)

Wiring Diagram

I try to create wiring diagrams for everything. I use Fritzing because it’s simple and awesome and open and free. I often don’t find the components I need, but you can always just use a note and some text.

Here’s the script/sequence for the lights:

  1. Green Light is ON
  2. Walk Light is ON
  3. Waiting 4 seconds…
  4. Walk Light is OFF
  5. Don’t Walk Light is BLINKING (for 5 seconds)
  6. Green Light is OFF
  7. Don’t Walk Light is ON
  8. Yellow Light is ON
  9. Waiting 4 seconds…
  10. Yellow Light is OFF
  11. Red Light is ON
  12. Waiting 6 seconds…
  13. Red Light is OFF
  14. Don’t Walk Light is OFF
  15. (Repeat sequence)

I wrote this up to figure out how to program things. I find it helpful to plan things out before I start writing the code.

At first I just talked through the light sequence with someone and we made some assumptions about how it worked. We were slightly wrong, which I discovered when I dug a bit deeper into traffic lights and walk signals. I read at least some of the (very long) Wikipedia page on Traffic Lights. I also hunted for other info, and found some on the Signals FAQ page on the Minnesota Department of Transportation web site. (As I mentioned with the 911 Phone I really do aim for an accurate and realistic experience with these things.)

It’s been a few weeks and the lights have been working fine. Hopefully that will continue to be the case. If something does stop working we’ll open a ticket for it so we have a record. And yes, we do use an issue tracker for our museum exhibits… doesn’t everyone?

« Older Entries |


buy the button:

Buy The Button