Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.11 KB | None | 0 0
  1. const int buttonPinW = 2; // Schalter Weiß Licht
  2. const int buttonPinB = 3; // Schalter Blau Licht
  3. const int buttonPinM = 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 fadeValueW = 0;
  10. int fadeValueB = 0;;
  11.  
  12. void setup() {
  13.   pinMode(ledPinW, OUTPUT);
  14.   pinMode(ledPinB, OUTPUT);
  15.   pinMode(buttonPinW, INPUT_PULLUP);
  16.   pinMode(buttonPinB, INPUT_PULLUP);
  17.   altMillis = millis();
  18. }
  19.  
  20. void loop() {
  21.   if (millis() - altMillis >= 100) {
  22.     altMillis = millis();
  23.  
  24.     if (digitalRead(buttonPinW)) {
  25.       if (fadeValueW < 255) {
  26.         fadeValueW++;
  27.       }
  28.     } else {
  29.       if (fadeValueW > 0) {
  30.         fadeValueW--;
  31.       }
  32.     }
  33.     analogWrite(ledPinW, fadeValueW);
  34.  
  35.     if (digitalRead(buttonPinB)) {
  36.       if (fadeValueB < 255) {
  37.         fadeValueB++;
  38.       }
  39.     } else {
  40.       if (fadeValueB > 0) {
  41.         fadeValueB--;
  42.       }
  43.     }
  44.     analogWrite(ledPinB, fadeValueB);
  45.  
  46.   }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement