loading
How it works:
http://www.youtube.com/watch?v=2MnkE1xXlKI

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:
-Soldering Gun
-Wire cutters

Stuff you're going to need:
-Solder wire
-DC coaxial plug 2.5mm x 5.5mm
-9V Battery Snap Connectors
-9V Battery
-Electrical tape
-4 x LEDs (5mm, 2.6 Volt, 28mA)
-Push Button Switch (Screw Terminal, 15A- 125 VAC, 10 A -250VAC)
-Hook-up wire
-10 x small jumper wire
-Cable Ties
-Project Box

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


Soldering LEDs
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.


Push button 
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.

Jumper wires
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

To program the switch into the arduino I followed this video: http://www.youtube.com/watch?v=_LCCGFSMOr4
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
int ledPinb=6;
int ledPinc=5;
int ledPind=4;
int ledPine=3;
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 ()
{
pinMode(switchPin, INPUT);
pinMode(ledPina, OUTPUT);
pinMode(ledPinb,OUTPUT);
pinMode(ledPinc,OUTPUT);
pinMode(ledPind, OUTPUT);
pinMode(ledPine, OUTPUT);

}
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
}

void loop()
{
currentButton=debounce(lastButton);//
if (lastButton==LOW && currentButton== HIGH)
{
ledOn=!ledOn; //inverts the value of LED from what it previously was
}

{
lastButton= currentButton;// Gets set to current button
digitalWrite(ledPina,ledOn);
digitalWrite(ledPinb,ledOn);
digitalWrite(ledPinc,ledOn);
digitalWrite(ledPind,ledOn);
digitalWrite(ledPine,ledOn);
}
}

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

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

Circuit
I enclosed the circuit using the project box. 

Push button
I mounted it using a cable tie!

Wiring
Used cable ties all the way. 

Step 5: Extras

Here's some data on input and output voltages that I collected: http://figshare.com/articles/Arduino_project_voltages.xls/92054

About This Instructable

3,737views

2favorites

License:

More by mxbenjo:On-Off Basket Bike Lights Using Arduino Uno 
Add instructable to: