AbstractBeliefs

Untitled

Jun 5th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. volatile unsigned char brightness = 0;
  2.  
  3. void tick(){
  4.   if (digitalRead(3) == HIGH){
  5.     if (brightness == 255){return;}
  6.     brightness++;
  7.     return;
  8.   }
  9.  
  10.   if (brightness == 0){return;}
  11.   brightness--;
  12.   return;
  13. }
  14.  
  15. void setup(){
  16.   pinMode(5, OUTPUT);
  17.   attachInterrupt(0, tick, RISING);
  18. }
  19.  
  20. void loop(){
  21.   analogWrite(5, brightness);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment