Advertisement
makispaiktis

ArduinoBasics - 5. Photoresistor controlling LED light - YT Version

Mar 21st, 2021 (edited)
928
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int value;
  2.  
  3. void setup()
  4. {
  5.   pinMode(A0, INPUT);
  6.   pinMode(11, OUTPUT);
  7.   Serial.begin(9600);
  8. }
  9.  
  10. void loop()
  11. {
  12.   value = analogRead(A0);
  13.   if(value <= 60){
  14.     value = 0;
  15.   }
  16.   if(value >= 970){
  17.     value = 1023;
  18.   }
  19.   value = map(value, 0, 1023, 0, 255);
  20.   analogWrite(11, value);
  21.   delay(10);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement