ChristineWu

Photoresistor LED

Dec 7th, 2016
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. //const int Button=7;
  2. const int PhotoPin=A0;
  3. const int LEDPin=5;
  4. int ReadValue=0;
  5. void setup()
  6. {
  7. pinMode (PhotoPin, INPUT);
  8. Serial.begin(9600);
  9. // put your setup code here, to run once:
  10.  
  11. }
  12.  
  13. void loop()
  14. {
  15. ReadValue=analogRead(PhotoPin);
  16. ReadValue=map (ReadValue,170,15,0,255);
  17. //these numbers indicate min (15) and max (170) and it inserts it into the readvalue)
  18. Serial.println(ReadValue);
  19. analogWrite (LEDPin, ReadValue);
  20. // put your main code here, to run repeatedly:
  21.  
  22. }
Add Comment
Please, Sign In to add comment