0% found this document useful (0 votes)
11 views

Cas Arduino

Uploaded by

haha32ab
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)
11 views

Cas Arduino

Uploaded by

haha32ab
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/ 2

int potPin=A0;

int Led[]={2,3,4,5};
int lastPotValue;
void setup() {
pinMode(potPin, INPUT);
for(int i=0;i<4;i++) {
pinMode(Led[i], OUTPUT);
//digitalWrite(Led[i],HIGH);
}
Serial.begin(9600);
}
void loop() {
int potValue=analogRead(potPin)/255;

if (potValue!=lastPotValue)
for(int i=0;i<4;i++) {
digitalWrite(Led[i],LOW);
}
switch(potValue)
{
case 0:
Serial.println("Very Low");
digitalWrite(Led[0], HIGH);
Serial.println(potPin);
delay(500);
break;
case 1:
Serial.println("Low");
Serial.println(potValue);
Serial.println(potPin);
digitalWrite(Led[1], HIGH);
delay(500);
break;
case 2:
Serial.println("Moderate");
Serial.println(potValue);
Serial.println(potPin);
digitalWrite(Led[2], HIGH);
delay(500);
break;
case 3:
Serial.println("High");
Serial.println(potValue);
digitalWrite (Led[3], HIGH);
delay(500);
break;
case 4:
Serial.println("Extreme");
Serial.println(potValue);
delay(500);
break;
default:
Serial.println("error");
Serial.println(potValue);
break;
}
lastPotValue=potValue;
}

You might also like