This is a project done for an introduction to electronics course.
[This is my open notebook for the course: http://mbenitez.iheartanthony.com/]
It's a really simple project combining a pushbutton, an arduino uno, and some LEDs.
The project I meant to do in the first place was to use the LEDs as turn signals but I don't know how to program this ...yet.
The main problems I have with programming are incorporating a second push button while making the LEDs blink.
For now, this is something I can do successfully.
However, I really want to branch off of this so any feedback is sooo very appreciated!!
Tools you're going to use:
Stuff you're going to need:
-DC coaxial plug 2.5mm x 5.5mm
-9V Battery Snap Connectors
-4 x LEDs (5mm, 2.6 Volt, 28mA)
-Push Button Switch (Screw Terminal, 15A- 125 VAC, 10 A -250VAC)
-10 x small jumper wire
Step 1: Arduino Battery Pack
To arm the arduino battery pack I followed this video: http://www.youtube.com/watch?v=zr-sVHnUACw
If you don't care whether your soldering comes out perfect or not, or if you're new to soldering (like me), a good way to ensure that you get a good connection is by placing the soldering gun on what you want to solder and just get a glob of solder enough to cover it.
Not very elegant, but it works!
Anyway, to solder this you want to thread the wires from the battery snap connectors into the DC coaxial plug so that when it's soldered it's pretty sturdy and won't come off.
You then slip the cover on and snap it onto the 9V battery.
Step 2: Soldering LEDs and Push Button
Cut 8 equal lengths of wire (long enough to attach the LEDs to the back of the basket) . Strip both ends off.
Solder LEDs and hookup wires together.
There's no need to solder to this push button since it has screws in as terminals. However you do need to cut two hookup wires of equal length (long enough to reach from the basket to the front of the bike).
Strip both ends off.
Solder the 10 jumper wires to one end of each piece of hook- up wire that was cut.
Lastly, place electrical tape on the soldered areas when done.
Step 3: Programming
This is the code I used:
int switchPin=8;// This is the pin the switch is connected to
int ledPina=7;//These are the pins the LEDs are connected to
boolean lastButton=LOW;// Keeps track of the value of the button in the previous loop
boolean ledOn=false;// Keeps track of the current state of the LED
boolean currentButton =LOW;// Keeps track of the current button value(Use it with debounce function)
void setup ()
boolean debounce (boolean last)// Creates a function called debounce with input last
boolean current =digitalRead (switchPin);// Determines the current value of the switch
if (last !=current)//
delay(5);// Gives switch enough time to finish debouncing
current=digitalRead(switchPin);// Here it’s read again, presuming that it’s at a steady value
return current;//This returns the steady value
if (lastButton==LOW && currentButton== HIGH)
ledOn=!ledOn; //inverts the value of LED from what it previously was
lastButton= currentButton;// Gets set to current button
Step 4: Mounting on Bike
When I started this project, I already had a basket attached to my bike. If you don't, it's fairly easy to do. The three things I used were: bike rack, super cheap basket, wire with hook (forgot what it's called, but it's pretty easy to find).
To get the LEDs on my basket I used the soldering gun to make four holes in my basket large enough to fit the LEDs in.
I enclosed the circuit using the project box.
I mounted it using a cable tie!
Used cable ties all the way.