Professional Documents
Culture Documents
AIM:
The main objective of this experiment is to read the analogue sensor value and Turn on Buzzer if
analogue sensor value exceeds its threshold value.
APPARATUS REQUIRED:
CONNECTION DIAGRAM:
PROCEDURE:
1. Give the connections to the Arduino board as shown in the connection diagram.
2. Open Arduino IDE in the computer
3. Create new file File_-- New
1
[IOT WORKSHOP][2022-2023]
PROGRAM:
int redled=3;
int greenled=2;
int buz=4;
int sensor = A0;
int sensThre = 400;
void setup()
{
pinMode(redled, OUTPUT);
pinMode(greenled, OUTPUT);
pinMode(buz, OUTPUT);
pinMode(sensor, INPUT);
5
Serial.begin(9600);
}
void loop()
{
int sensValue=analogRead(sensor);
Serial.println(sensValue);
if (sensValue > 300)
{
digitalWrite(redled, HIGH);
tone(buz,10000,10);
digitalWrite(greenled, LOW);
}
else
{
digitalWrite(greenled, HIGH);
noTone(buz);
digitalWrite(redled, LOW);
}
}
2
[IOT WORKSHOP][2022-2023]
RESULT: