0% found this document useful (0 votes)
20 views1 page

Prac 13

This Arduino code sets up an infrared sensor, an LED, and a buzzer. In the setup function, it initializes the pins for the sensor, LED, and buzzer. In the loop function, it reads the infrared sensor's state to control the LED and buzzer accordingly, turning the LED on and the buzzer off when the sensor detects an input, and vice versa when it does not.

Uploaded by

trishak2305
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Prac 13

This Arduino code sets up an infrared sensor, an LED, and a buzzer. In the setup function, it initializes the pins for the sensor, LED, and buzzer. In the loop function, it reads the infrared sensor's state to control the LED and buzzer accordingly, turning the LED on and the buzzer off when the sensor detects an input, and vice versa when it does not.

Uploaded by

trishak2305
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <Arduino.

h>
#define IR_PIN 8
#define LED 3
#define BUZZER 6

void setup() {
// put your setup code here, to run once:
pinMode(IR_PIN,INPUT);
pinMode(LED,OUTPUT);
pinMode(BUZZER,OUTPUT);

pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
digitalWrite(0,LOW);
digitalWrite(1,LOW);

digitalWrite(LED,LOW);
digitalWrite(BUZZER,HIGH);
//Serial.begin(9600);
// delay(500);
}

void loop() {
// put your main code here, to run repeatedly:
//Serial.print("OUTPUT: ");
//Serial.println(digitalRead(IR_PIN));
if(digitalRead(IR_PIN))
{
digitalWrite(LED,HIGH);
digitalWrite(BUZZER,LOW);
}
else
{
digitalWrite(LED,LOW);
digitalWrite(BUZZER,HIGH);
}
//delay(500);
}

You might also like