[vc_row][vc_column width=”1/1″][vc_column_text]The components used in this experiment are shown below:
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][/vc_column_text][/vc_tab][vc_tab title=”Wire Diagram” tab_id=”1392609550-2-88″][vc_column_text][/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]
Leave a Reply
You must be logged in to post a comment.