Guest User

Untitled

a guest
Jan 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. int ledPin = 9;
  2. int brightness = 0;
  3. boolean increase_brightness = true;
  4.  
  5. void setup(){
  6. pinMode(ledPin, OUTPUT);
  7. }
  8.  
  9. void loop(){
  10. if(brightness == 64 && increase_brightness)
  11. {
  12. increase_brightness = false;
  13. } else if (brightness == 0 && !increase_brightness){
  14. increase_brightness = true;
  15. }
  16.  
  17. if(increase_brightness)
  18. {
  19. brightness++;
  20. } else {
  21. brightness--;
  22. }
  23. analogWrite(ledPin, brightness);
  24.  
  25. delay(30);
  26. }
Add Comment
Please, Sign In to add comment