Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.09 KB | None | 0 0
  1. const int buttonPin  = 2; // Schalter Weiß Licht
  2. const int buttonPinB = 3; // Schalter Blau Licht
  3. const int buttonPinW = 4; // Schalter DC Motor Vliesfilter
  4. const int ledPinW   = 11; // Weiß led Stripe
  5. const int ledPinB   = 12; // Blaue led Stripe
  6. const int motorPin1 = 13; // Ausgang Motor Vliesfilter
  7. const int sensorPin  = 5; // Evt Bewegungsmelder
  8. uint32_t altMillis;
  9. int fadeValue_w = 0;
  10.  
  11.  
  12. void setup() {
  13.   pinMode(ledPinW, OUTPUT);
  14.   pinMode(ledPinB, OUTPUT);
  15.   pinMode(buttonPinB, INPUT_PULLUP);
  16.   pinMode(buttonPinW, INPUT_PULLUP);
  17. }
  18.  
  19. void loop() {
  20.   if (millis() - altMillis >= 100){
  21.     altMillis = millis();
  22.    
  23.     if (digitalRead(buttonPinW)){
  24.              if (fadeValue_w < 255) {
  25.           fadeValue_w++;
  26.         }
  27.     }else{
  28.       if (fadeValue_w > 0) {
  29.         fadeValue_w--;
  30.       }
  31.     }
  32.     analogWrite(ledPinW, fadeValue);
  33.    
  34.     if (digitalRead(buttonPinB)){
  35.              if (fadeValue_b < 255) {
  36.           fadeValue_b++;
  37.         }
  38.     }else{
  39.       if (fadeValue_b > 0) {
  40.         fadeValue_b--;
  41.       }
  42.     }
  43.     analogWrite(ledPinB, fadeValue);
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement