Advertisement
Guest User

Untitled

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