This is a project done for an introduction of freashers to electronics course.
It's a really simple and very easy 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 very valued here.
It's a really simple and very easy 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 very valued here.
Tools which I am using here:
1.Soldering Gun
2.Wire cutters
Stuff you're going to need:
1.Solder wire
2.DC coaxial plug 2.5mm x 5.5mm
3.9V Battery Snap Connectors
4.9V Battery
5.Electrical tape
6.4 LEDs (5mm, 2.6 Volt, 28mA)
7.Push Button Switch (Screw Terminal, 15A- 125 VAC, 10 A -250VAC)
8.Hook-up wire
9.10 small jumper wire
10.Cable Ties
11.Project Box
Step 1: BATTERY PACK OF ARDUINO
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 are getting 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 attractive ,strong and won't come off.
You then slip the cover on and snap it onto the 9V battery.
Step 2:LED’S SOLDERING AND PUSH BUTTON
Soldering LED's
Cut 8 equal lengths of wire (long enough to attach the LED's to the back of the basket) . Strip both ends off.
Solder LED's 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.
Cut 8 equal lengths of wire (long enough to attach the LED's to the back of the basket) . Strip both ends off.
Solder LED's 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.
Step 3: Programming

To program the switch
into the arduino I followed this
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);
}
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: Moulding on Bike
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!
Wiringsed cable ties all the way.
Circuit
I enclosed the circuit using the project box.
Push button
I mounted it using a cable tie!
Wiringsed cable ties all the way.
CONCLUSION
Now our project are ready. Moulding alight in the basket
is not a difficult task but do the
programming on the Arduino board is very carefully.And all wires connect very
carefully.
No comments:
Post a Comment