Advertisement
JNET

Photoresistor 1

Dec 8th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. const int PhotoR = A0;
  2. const int LEDpin = 5;
  3. int ReadValue = 0;
  4.  
  5. void setup()
  6. {
  7. pinMode (PhotoR, INPUT);
  8. pinMode (LEDpin, OUTPUT);
  9. Serial.begin(9600);
  10. }
  11.  
  12. void loop()
  13. {
  14. ReadValue = analogRead(PhotoR);
  15. ReadValue = map(ReadValue, 13, 493, 255, 0);
  16. ReadValue = constrain(ReadValue, 0, 255);
  17. Serial.println(ReadValue);
  18. analogWrite(LEDpin, ReadValue);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement