Advertisement
carolineSgreenhill

Turning Off and On a Light with a Photosensor

Dec 6th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. /*Caroline Sasso*
  2. * My Program
  3. * 11/30/2016
  4. */
  5. const int PhotoPin=A0;
  6. int ReadValue=0;
  7. const int LEDPin=4;
  8.  
  9. void setup()
  10. {
  11. pinMode (PhotoPin, INPUT);
  12. pinMode (LEDPin, OUTPUT);
  13. Serial.begin(9600);
  14. }
  15. void loop()
  16. {
  17. ReadValue = analogRead (PhotoPin);
  18. Serial.println (ReadValue);
  19. analogWrite (LEDPin, 255-ReadValue*255/103);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement