Tuesday, November 29, 2011

Part 4b - The Hardware parts continued

The ShiftBrite LED

Implementing the Shiftbrite with the Arduino wasn't that difficult. I thought there would be a lot of software involved, but the Arduino recommended a open source library to use to make things considerably easier. The library was called 'HughesyShiftbrite', I got the link from the Arduino website and downloaded it off code.google.

Shiftbrite connected to Arduino
For this particular project I wanted it to act as a warning light, so although it can be used for a lot of different things, I was just using it on a basic level.
Connecting to the Arduino involved 6 pins. The Vcc, Gnd and 4 other pins to control the Shiftbrite. You can declare these pins as a variable using the software library. In my case I used the following; sb = HughesyShiftBrite(5,4,3,2). This declared that the numbered pins are connected to the Data I, Latch I, Enable I and Clock I pins on the Shiftbrite respectively. The remaining pins on the Shiftbrite aren't used in this project.

Different angle capturing the shiftbrite
The Shiftbrite LED works using 3 colours, red, green and blue. Each colour have 10 bits each so that's 1024 different combinations on each colour. Combining the 3 colours gives over a billion different combinations, I'll be using 3. Red, green and orange. Setting the colours are easy enough using a function from the library. An example of this would be sb.sendColour(1023,0,0); where sb is just the variable I called the actual shiftbrite, and the function sendColour sets the red colour value at 1023 and the green and blue values at 0, making the shiftbrite emit a red light.

I used simple if statements to determine the colour of the shiftbrite depending on the distance of the obstruction determined from the Ultrasonic sensor. Green for safe, orange for warning and red for stop. It's very simple, I know, but it will work in my system.

No comments:

Post a Comment