Advertisement
rosea4

code 3-3 in black book

Mar 24th, 2015
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. const int BLED= 9 ;
  2. const int Light= 0 ;
  3. const int Minlight = 400 ;
  4. const int Maxlight = 850 ;
  5. int val= 0 ;
  6. void setup ()
  7. {
  8. pinMode (BLED, OUTPUT) ;
  9. pinMode (Light, INPUT) ;
  10. Serial.begin (9600) ;
  11. }
  12. void loop ()
  13. {
  14. val = analogRead(Light) ;
  15. Serial.print(val);
  16. Serial.print(" ");
  17. delay(50);
  18. val = map(val, Minlight, Maxlight, 255, 0) ;
  19. val = constrain(val, 0, 255) ;
  20. Serial.println(val);
  21. analogWrite (BLED, val) ;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement