Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #define led 11
  2. #define butt_up 8
  3. #define butt_down 9
  4.  
  5. int brigthness = 0;
  6. void setup() {
  7.   pinMode(led, OUTPUT);
  8.   pinMode(butt_up, INPUT_PULLUP);
  9.   pinMode(butt_down, INPUT_PULLUP);
  10. }
  11. void loop() {
  12.   if (digitalRead(butt_up) == 0) {
  13.     brigthness = brigthness + 10;
  14.   } else if (digitalRead(butt_down) == 0){
  15.     brigthness = brigthness - 10;
  16.   }
  17.  
  18.   if (brigthness > 255) {
  19.     brigthness = 255;
  20.   }
  21.   if (brigthness < 0) {
  22.     brigthness = 0;
  23.   }
  24.  
  25.   analogWrite(led,brigthness);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement