Wednesday 21 March 2018

How To Use Infrared (IR) sensor with Arduino

the code i used is :
int value;
int ledPin = 13;
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode (ledPin,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
value  = analogRead(A0);
if (value<100){
  digitalWrite(ledPin,HIGH);
  Serial.println(value);
 
}else {
  digitalWrite(ledPin,LOW);
  Serial.println(value);
}

 delay(1);
}