Page 24 - S.Shafna (1B), 2207, Ass-1
P. 24
for(int i = 0;i<=50;i++){
int lightlevel = analogRead(sensorpin);
lightlevel = map (lightlevel, 0,900,0,255);
lightlevel = constrain (lightlevel, 0, 255);
delay(1);
Serial.print("Red = "); Serial.println(lightlevel);
}
digitalWrite(Redled, LOW);
delay (2000);
digitalWrite(Blueled, HIGH);
for(int i = 0;i<=50;i++){
int lightlevel = analogRead(sensorpin);
lightlevel = map (lightlevel, 0,900,0,255);
lightlevel = constrain (lightlevel, 0, 255);
delay(1);
Serial.print("Blue = "); Serial.println(lightlevel);
}
delay (2000);
}
❖ Output