You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
538 B
27 lines
538 B
3 years ago
|
//www.elegoo.com
|
||
|
//2016.12.08
|
||
|
/*****************************************/
|
||
|
const int ledPin = 13;//the led attach to
|
||
|
|
||
|
void setup()
|
||
|
{
|
||
|
pinMode(ledPin,OUTPUT);//initialize the ledPin as an output
|
||
|
pinMode(2,INPUT);
|
||
|
digitalWrite(2, HIGH);
|
||
|
}
|
||
|
/******************************************/
|
||
|
void loop()
|
||
|
{
|
||
|
int digitalVal = digitalRead(2);
|
||
|
if(HIGH == digitalVal)
|
||
|
{
|
||
|
digitalWrite(ledPin,LOW);//turn the led off
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
digitalWrite(ledPin,HIGH);//turn the led on
|
||
|
}
|
||
|
}
|
||
|
/**********************************************/
|
||
|
|