0% found this document useful (0 votes)
19 views2 pages

Sound Sensor With Led

Uploaded by

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

Sound Sensor With Led

Uploaded by

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

#define LED_1 2 ledPin2Status = 1;

#define LED_2 3
#define LED_3 4 if (sensorValue > 560 )
#define LED_4 5 ledPin3Status = 1;
#define LED_5 6
#define sensorPin A0 // Analog input pin that the Sensor is attached to if (sensorValue > 562 )
ledPin4Status = 1;
bool ledPin1Status;
bool ledPin2Status; if (sensorValue > 564 )
bool ledPin3Status; ledPin5Status = 1;
bool ledPin4Status;
bool ledPin5Status; if (ledPin1Status == 1 || ledPin2Status == 1 || ledPin3Status == 1 || ledPin4Status == 1 || ledPin5Status == 1)
{
void setup() { if (sensorValue > 555 || sensorValue < 537 )
pinMode(LED_1, OUTPUT); digitalWrite(LED_1, HIGH);
pinMode(LED_2, OUTPUT);
pinMode(LED_3, OUTPUT); if (sensorValue > 558 || sensorValue < 534 )
pinMode(LED_4, OUTPUT); digitalWrite(LED_2, HIGH);
pinMode(LED_5, OUTPUT);
if (sensorValue > 560 || sensorValue < 534 )
pinMode(sensorPin, INPUT); digitalWrite(LED_3, HIGH);

Serial.begin(9600);// initialize serial communications at 9600 bps: if (sensorValue > 562 || sensorValue < 531 )
} digitalWrite(LED_3, HIGH);

void loop() {
if (sensorValue > 564 || sensorValue < 528)
int sensorValue = analogRead(sensorPin); digitalWrite(LED_4, HIGH);
Serial.println(sensorValue);
if (sensorValue > 568 || sensorValue < 525)
if (sensorValue > 555 ) digitalWrite(LED_5, HIGH);
ledPin1Status = 1;
delay(200);
if (sensorValue > 558 )
ledPin5Status = 0;
ledPin4Status = 0;
ledPin3Status = 0;
ledPin2Status = 0;
ledPin1Status = 0;

digitalWrite(LED_1, LOW);
digitalWrite(LED_2, LOW);
digitalWrite(LED_3, LOW);
digitalWrite(LED_4, LOW);
digitalWrite(LED_5, LOW);

You might also like