Advertisement
ambersy314

Untitled

Jun 14th, 2017
64
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 photoPin=A0;
  2. int photoValue=0;
  3. int lightVal=0;
  4.  
  5. void setup()
  6. {
  7. // put your setup code here, to run once:
  8.  
  9. Serial.begin(9600);
  10. pinMode(photoPin, INPUT);
  11.  
  12. }
  13.  
  14. void loop()
  15. {
  16. // put your main code here, to run repeatedly:
  17. photoValue=analogRead (photoPin);
  18. lightVal=map (photoValue, 0, 907, 255, 0);
  19. lightVal=constrain (lightVal, 0, 255);
  20. Serial.print ("Photoresistor value =");
  21. Serial.print(photoValue);
  22. Serial.print ("lightVal =");
  23. Serial.println(lightVal);
  24. delay (100);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement