DILLA2

1b

Jan 24th, 2021
796
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define LED_GREEN 12
  2. #define LED_RED 11
  3. unsigned long old_green_millis = millis();
  4. unsigned long old_red_millis = millis();
  5. int max_interval = 1000;
  6. int min_interval = 10;
  7.  
  8. void setup() {
  9.   pinMode(LED_GREEN, OUTPUT);
  10.   pinMode(LED_RED, OUTPUT);
  11.   Serial.begin(9600);
  12.  
  13. }
  14.  
  15. void loop() {
  16.   int green_interval = max_interval;
  17.   int red_interval = min_interval;
  18.  
  19.   while ((green_interval >= min_interval) and
  20.          (red_interval <= max_interval)) {
  21.  
  22.     if (millis() - old_green_millis >= green_interval) {
  23.       digitalWrite(LED_GREEN, !digitalRead(LED_GREEN));
  24.       green_interval -= 20;
  25.       old_green_millis = millis();
  26.     }
  27.  
  28.     if (millis() - old_red_millis >= red_interval) {
  29.       digitalWrite(LED_RED, !digitalRead(LED_RED));
  30.       red_interval += 10;
  31.       old_red_millis = millis();
  32.     }
  33.   }
  34.   Serial.println("UTE");
  35. }
RAW Paste Data