Learning Colors Using Arduino
by hsuaitingg in Circuits > Arduino
150 Views, 0 Favorites, 0 Comments
Learning Colors Using Arduino
This project is to help children who aged 2-4 years old.
There will be three different colors of LED, and when you press the bottom, one random LED will light up.
For more advanced, if you want your children to learn more, you can press the bottom 3~5 seconds without moving your hands, and also 2 random colors of LEDs will light up, and your children have to answer what is the color of 2 LED light up be like. For example, if the LED lighted up blue and red, your children have to answer ' purple'.
Supplies
LED light -
Orange X1
Blue X1
White X1
Orange X1
Short wires X10
Medium wires X9
Breadboard X1
Arduino Leonardo USB line X1
Thick tracing paper x1
Button X2
Construct the Circuit
Creating Your Code
void setup(){ // put your setup code here, to run once:
pinMode( 2 , INPUT); // sets the digital pin as input
pinMode( 12 , OUTPUT); // sets the digital pin as output
pinMode( 11 , OUTPUT); // sets the digital pin as output
pinMode( 3 , INPUT); // sets the digital pin as input
pinMode( 10 , OUTPUT); // sets the digital pin as output
pinMode( 9 , OUTPUT); // sets the digital pin as output
}
void loop(){ // put your main code here, to run repeatedly:
if (digitalRead( 2 )) {
digitalWrite( 12 , HIGH ); // sets the digital pin on/off
digitalWrite( 11 , LOW ); // sets the digital pin on/off
}
else {
digitalWrite( 10 , LOW ); // sets the digital pin on/off
digitalWrite( 9 , HIGH ); // sets the digital pin on/off
}
}