Docsity

IOT Practical 2 code TE AIDS SPPU 2024 Pattern, Study Guides, Projects, Research of Internet and Information Access

Toggle sidebar
bg1
#define IRpin 2
#define ledPin 13
void setup()
{
pinMode(IRpin,INPUT);
pinMode(ledPin,OUTPUT);
}
void loop()
{
int sensorValue = digitalRead(IRpin); // Read the IR sensor output
if (sensorValue == LOW)
{
digitalWrite(ledPin, HIGH);
Serial.println("Obstacle detected!");
}
else
{
digitalWrite(ledPin, LOW);
Serial.println("No obstacle.");
}
}
OUTPUT:
pf3

Partial preview of the text

Download IOT Practical 2 code TE AIDS SPPU 2024 Pattern and more Study Guides, Projects, Research Internet and Information Access in PDF only on Docsity!

#define IRpin 2 #define ledPin 13 void setup() { pinMode(IRpin,INPUT); pinMode(ledPin,OUTPUT); } void loop() { int sensorValue = digitalRead(IRpin); // Read the IR sensor output if (sensorValue == LOW) { digitalWrite(ledPin, HIGH); Serial.println("Obstacle detected!"); } else { digitalWrite(ledPin, LOW); Serial.println("No obstacle."); } }

OUTPUT: