Quickly Distinguish Colors
這個裝置是幫助0-5歲的小朋友識別顏色。會有四顆不一樣的LED 按按鈕時會亮不同顏色的燈泡。小孩就要馬上回答那是什麼顏色,更進階的是,會同時亮兩顆燈泡使用者就要馬上說出這兩的顏色加起來會變什麼顏色。
This device is to help children aged 0-5 to identify colors. There will be four different LEDs that will light up bulbs of different colors when you press the button. The child should immediately answer what color it is. More advanced, the user who will light up two light bulbs at the same time should immediately tell what color the two colors will change.
Supplies You Need
LED light -
Orange X1
Blue X1
White X
Orange X1
Short wires X10
Medium wires X9
Breadboard X1
Arduino Leonardo USB line X1
Thick tracing paper x1
Button X2
Creating the Electric Circuit
Creating the 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( 12 , LOW ); // sets the digital pin on/off
digitalWrite( 11 , HIGH ); // sets the digital pin on/off
}
if (digitalRead( 3 )) {
digitalWrite( 10 , HIGH ); // sets the digital pin on/off
digitalWrite( 9 , 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
}
}