Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int light;
- int ledPin = 11;
- void setup()
- {
- Serial.begin(9600);
- pinMode(A0, INPUT);
- pinMode(ledPin, OUTPUT);
- }
- void loop()
- {
- light = analogRead(A0);
- Serial.print("Light is = ");
- Serial.println(light);
- // Light can take values from 54 to 974
- light = map(light, 0, 1023, 0, 255);
- Serial.print("Regularised light is = ");
- Serial.println(light);
- analogWrite(ledPin, light);
- delay(200);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement