• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeArduinoAdvanced Learning Kit for ArduinoExperiment 3 Experiment with Button
Previous Next

Experiment 3 Experiment with Button

Posted by: Alvin Jin , February 17, 2014

[vc_row][vc_column width=”1/1″][vc_column_text]The components used in this experiment are shown below:

QQ截图20140217120146

The components are one LED, one button, one IOK  ohm resistor,one 470 ohm resistor,5 jumper wires, and one breadboard.[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Schematics” tab_id=”1392609550-1-29″][vc_column_text]QQ截图20140217120603[/vc_column_text][/vc_tab][vc_tab title=”Wire Diagram” tab_id=”1392609550-2-88″][vc_column_text]QQ截图20140217120902[/vc_column_text][/vc_tab][vc_tab title=”Arduinmo Code” tab_id=”1392610180612-2-5″][vc_column_text]int key=7;//Configure the button ON/OFF indicator digital IO pin,
which is wired to LED
void setup()
{
pinMode(key,OUTPUT);//Set the mode of the ON/OFF indicator digital IO
pin to be OUTPUT
}
void loop()
{
int i;//define a variable
while(1)
{
i=analogRead(5);//Read analog input port 5
if(i>1000)//if the value is larger than 1000(i.e., 4.88V)
//set the indicator pin to be HIGH to turn on the LED

digitalWrite(key,HIGH);
else
//set the indicator pin to be LOW to turn off the LED
digitalWrite(key,LOW);
}
}

[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]

Tags: Advanced Learning Kit for Arduino

Share!
Tweet

Alvin Jin

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors