Posts Tagged ‘HiTechnic’

Friday Night Robotics – MusicBox!

Posted by Erin, the RobotGrrl on Sunday, October 11th, 2009

This Friday I had the most awesome idea of a weekend project ever! A 21st century MusicBox, using an Arduino and have blinking LEDs!

I had a Sparkfun box lying around, which is an ideal size for an Arduino and a WaveShield.

Friday Night Robotics - MusicBox!

I wanted to have LEDs outlining the box, so I went to work on it:

Friday Night Robotics - MusicBox!

Friday Night Robotics - MusicBox!

Just as a disclaimer- I designed it wrong, so the LEDs don’t work well. If you’re looking to follow my steps, DON’T DO IT! :P

Friday Night Robotics - MusicBox!

Friday Night Robotics - MusicBox!

Then, installing them into the box:

Friday Night Robotics - MusicBox!

It looks nice!

Friday Night Robotics - MusicBox!

Once all of the connections are made, it’s pretty tight in there:

Friday Night Robotics - MusicBox!

The problem though, is that I designed it so that all the LEDs are in series. Since al LEDs aren’t created equally, some suck up more power and therefore can’t share it with the others. This is what happened:

Friday Night Robotics - MusicBox!

It’s pretty sad! :( But, I think that I can fix it because I soldered the resistors together, not the actual LEDs together. :D I was too excited to start this project, so I didn’t bother to plan =) I guess planning would have been better, but it would also have been too boring.

I also worked on a NXT LED blinky thingy. There are these HiTechnic Protoboards that you can get, and basically you attach them to one of the sensor inputs, and you can control power to certain ports and such.

In this case, there’s 6 output pins that you can control. Sounds like an opportunity to use LEDs to me! :D

NXT + LEDs

This is what the setup looks like:

NXT + LEDs

It goes like this: NXT -> HiTechnic ProtoBoard Sensor Adapter -> 6 LEDs

In order to output instructions to the HiTechnic ProtoBoard, you need ‘drivers’, or headers. They’re located here.

Here is the code for the LEDs, in RobotC:

  1. #pragma config(Sensor, S1,     HTPB,                sensorI2CCustom9V)
  2. //*!!Code automatically generated by ‘ROBOTC’ configuration wizard               !!*//
  3.  
  4. /*
  5.   Crazy LEDs!
  6.   Erin K
  7.   Oct. 9th, 2009
  8. */
  9.  
  10. #include "drivers/common.h"
  11. #include "drivers/HTPB-driver.h"
  12.  
  13. byte theLEDs[] = { 0×01, 0×02, 0×04, 0×08, 0×10, 0×20 };
  14.  
  15. task main() {
  16.  
  17.   // Setup all the digital IO ports as outputs (0xFF)
  18.   if (!HTPBsetupIO(HTPB, 0xFF)) StopAllTasks();
  19.   wait1Msec(200);
  20.  
  21.   while(true) {
  22.  
  23.     // The delay time
  24.     int theTime = 50;
  25.  
  26.     // LEDs going up
  27.     for(int i=0; i<6; i++) {
  28.       if (!HTPBwriteIO(HTPB, theLEDs[i])) nxtDisplayTextLine(5, "ERR WRITE");
  29.       wait1Msec(theTime);
  30.     }
  31.  
  32.     // LEDs going down
  33.     for(int i=5; i>=0; i) {
  34.       if (!HTPBwriteIO(HTPB, theLEDs[i])) nxtDisplayTextLine(5, "ERR WRITE");
  35.       wait1Msec(theTime);
  36.     }
  37.  
  38.     alive();
  39.  
  40.   }
  41.  
  42. }

This is what the code does:

To wrap up this Friday Night Robotics, I checked out the Adafruit Ask an Engineer chat. It was pretty cool! I learnt about how LEDs work, and how much it costs to create a Teenyduino! Everyone should check it out, Saturday at 10:00PM EST.

The only things that I didn’t get to do that I wanted to was play with MANOI and the iRobot Create. I’m kinda worried that MANOI’s batteries are drying out as they haven’t been exercised in a while :S EEP!

Posted in: Art, Programming, Projects, Robot.