int pot = A0;
int red = 11;
int blue = 8;
int green = 9;
void setup() {
// put your setup code here, to run once:
pinMode(pot, INPUT);
Serial.begin(9600);
pinMode(red, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(green, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int pot_val = analogRead(pot);
int brightness = pot_val/4;
//analogWrite(red,brightness);
int value = analogRead(pot);
//Serial.print("Potentiometer value =");
//Serial.println(value);
//Serial.print("Led value = ");
//Serial.println(brightness);
delay(600);
if(brightness<=100)
{
digitalWrite(red, HIGH);
digitalWrite(blue, LOW);
digitalWrite(green, LOW);
Serial.println("LED value is less than 100 (="+String(brightness)+")");
}
else if ((brightness>100) && brightness<150)
{
digitalWrite(red, LOW);
digitalWrite(blue, HIGH);
digitalWrite(green, LOW);
Serial.println("LED value is in the range of 100 and 150(="+String(brightness)+")");
}
else{
digitalWrite(red, LOW);
digitalWrite(blue, LOW);
digitalWrite(green, HIGH);
Serial.println("LED value is greater than 150(="+String(brightness)+")");
}
}