Advertisement
RuiViana

MyDimmer_JAN

Sep 16th, 2021
1,136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. void myDimmer()
  2. {
  3.   if ( digitalRead(decPin) == LOW)
  4.   {
  5.     flag = 0;
  6.     delay(200);
  7.   }
  8.  
  9.   if (digitalRead(incPin) == LOW)
  10.   {
  11.     flag = 1;
  12.     delay(200);
  13.   }
  14.     switch (flag)
  15.   {
  16.     case 0:
  17.       intensidadeRed += 13000;
  18.       if (intensidadeRed  > 130000)
  19.         intensidadeRed = 130000;
  20.       Serial.println(intensidadeRed);
  21.       break;
  22.  
  23.     case 1:
  24.       intensidadeRed -= 13000;
  25.       if (intensidadeRed  < 0)
  26.         intensidadeRed = 0;
  27.       Serial.println(intensidadeRed);
  28.       break;
  29.  
  30.     default:
  31.       break;
  32.   }
  33.   flag = 2;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement