keyestudio
www.keyestudio.com
while(1)
{
i=analogRead(5);// read the voltage value of analog pin 5
if(i>512)// if larger that 512(2.5V)
{
digitalWrite(8,LOW);// turn on LED
}
else// otherwise
{
digitalWrite(8,HIGH);// turn off LED
}
}
}
//////////////////////////////////////////////////////////
Test Result
Hold the breadboard with your hand. Tilt it to a certain extent, the LED will be on. If there is no
tilt, the LED will be off.
The principle of this experiment can be also applied to relay control.
Experiment now is completed. Thank you!
*******************************************************************************
Project 14: IR Remote Control