int LED_1 = 2;
int LED_2 = 3;
int LED_3 = 4;
int LED_4 = 5;
int LED_5 = 6;
#define sensorPin A0 // Analog input pin that the Sensor is attached to
void setup() {
pinMode(LED_1, OUTPUT);
pinMode(LED_2, OUTPUT);
pinMode(LED_3, OUTPUT);
pinMode(LED_4, OUTPUT);
pinMode(LED_5, OUTPUT);
pinMode(sensorPin, INPUT);
Serial.begin(9600);// initialize serial communications at 9600 bps:
}
void loop() {
int sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
//LED_1
if(sensorValue > 0 ){
digitalWrite(LED_1, HIGH);
}
else {
digitalWrite(LED_1, LOW);
}
//LED_2
if(sensorValue > 200 ){
digitalWrite(LED_2, HIGH);
}
else {
digitalWrite(LED_2, LOW);
}
//LED_3
if(sensorValue > 400 ){
digitalWrite(LED_3, HIGH);
}
else {
digitalWrite(LED_3, LOW);
}
//LED_4
if(sensorValue > 600 ){
digitalWrite(LED_4, HIGH);
}
else {
digitalWrite(LED_4, LOW);
}
//LED_5
if(sensorValue > 800){
digitalWrite(LED_5, HIGH);
}
else {
digitalWrite(LED_5, LOW);
}
}