My code doesn't work all of the leds go on but they dont go off? (Question on image)O My code: const int ROOD = 12; const int BLAUW = 13; const int RGBROOD = 9; const int RGBBLAUW = 10; const int RGBGROEN = 11; int count1 = 0; int count2 = 0; int count3 = 0; int count4 = 0; void setup() {   pinMode(ROOD, OUTPUT);   pinMode(BLAUW, OUTPUT);   pinMode(RGBROOD, OUTPUT);   pinMode(RGBBLAUW, OUTPUT);   pinMode(RGBGROEN, OUTPUT); } void loop() {    delay(1000);     count1 +=1;     if (count1 == 5) {       count1 -= 5;     }     count2 +=1;     if (count2 == 6) {       count2 -= 6;     }     count3 +=1;     if (count3 == 4) {       count2 -= 4;     }     count4 +=1;     if (count4 == 7) {       count4 -= 7;     }     if (count1 == 1) {       digitalWrite(BLAUW, 1);     }     if (count1 > 6 && count1 < 1) {       digitalWrite(BLAUW, 0);     }     if (count2 < 5) {       digitalWrite(ROOD, 1);     }     if (count2 < 7 && count2 > 4) {       digitalWrite(ROOD, 0);     }     if (count3 < 4) {       digitalWrite(RGBROOD, 1);     }     if (count3 = 4) {       digitalWrite(RGBROOD, 0);     }     if (count4 < 6) {       digitalWrite(RGBGROEN, 1);     }     if (count4 < 8 && count4 > 5) {       digitalWrite(RGBGROEN, 0);     }     if (count1 < 3) {       digitalWrite(RGBBLAUW, 1);     }     if (count1 > 2 && count1 < 6) {       digitalWrite(RGBBLAUW, 0);     }   }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

My code doesn't work all of the leds go on but they dont go off? (Question on image)O

My code:

const int ROOD = 12;
const int BLAUW = 13;
const int RGBROOD = 9;
const int RGBBLAUW = 10;
const int RGBGROEN = 11;
int count1 = 0;
int count2 = 0;
int count3 = 0;
int count4 = 0;

void setup() {
  pinMode(ROOD, OUTPUT);
  pinMode(BLAUW, OUTPUT);
  pinMode(RGBROOD, OUTPUT);
  pinMode(RGBBLAUW, OUTPUT);
  pinMode(RGBGROEN, OUTPUT);
}

void loop() {

   delay(1000);

    count1 +=1;
    if (count1 == 5) {
      count1 -= 5;
    }
    count2 +=1;
    if (count2 == 6) {
      count2 -= 6;
    }
    count3 +=1;
    if (count3 == 4) {
      count2 -= 4;
    }
    count4 +=1;
    if (count4 == 7) {
      count4 -= 7;
    }

    if (count1 == 1) {
      digitalWrite(BLAUW, 1);
    }
    if (count1 > 6 && count1 < 1) {
      digitalWrite(BLAUW, 0);
    }

    if (count2 < 5) {
      digitalWrite(ROOD, 1);
    }
    if (count2 < 7 && count2 > 4) {
      digitalWrite(ROOD, 0);
    }

    if (count3 < 4) {
      digitalWrite(RGBROOD, 1);
    }
    if (count3 = 4) {
      digitalWrite(RGBROOD, 0);
    }

    if (count4 < 6) {
      digitalWrite(RGBGROEN, 1);
    }
    if (count4 < 8 && count4 > 5) {
      digitalWrite(RGBGROEN, 0);
    }

    if (count1 < 3) {
      digitalWrite(RGBBLAUW, 1);
    }
    if (count1 > 2 && count1 < 6) {
      digitalWrite(RGBBLAUW, 0);
    }
  }
2.6. Arbitrary LED control
Create a new Arduino sketch.
Write a program in which:
-
-
each LED is periodically turned on and off for the timespans given in the table below.
All LED's perform their loop in parallel, i.e. they all run at the same time
LED
Period time [s]
Blue LED on Arduino shield
5
Red LED on Arduino shield
6
R-LED of RGB-LEDs on Arduino shield
4
G-LED of RGB-LEDs on Arduino shield 7
B-LED of RGB-LEDs on Arduino shield 5
On-time [s]
1
4
3
5
2
Off-time [s]
4
2
1
2
3
Hint: Define a global integer variable count and initialize it to 0.
In the loop() function, the variable count is increased each second by 1.
To control each LED, calculate the remainder of the integer division of variable count and the period
time of a LED. Turn on the LED if the result is less than the on-time of the LED, otherwise turn it off.
Transcribed Image Text:2.6. Arbitrary LED control Create a new Arduino sketch. Write a program in which: - - each LED is periodically turned on and off for the timespans given in the table below. All LED's perform their loop in parallel, i.e. they all run at the same time LED Period time [s] Blue LED on Arduino shield 5 Red LED on Arduino shield 6 R-LED of RGB-LEDs on Arduino shield 4 G-LED of RGB-LEDs on Arduino shield 7 B-LED of RGB-LEDs on Arduino shield 5 On-time [s] 1 4 3 5 2 Off-time [s] 4 2 1 2 3 Hint: Define a global integer variable count and initialize it to 0. In the loop() function, the variable count is increased each second by 1. To control each LED, calculate the remainder of the integer division of variable count and the period time of a LED. Turn on the LED if the result is less than the on-time of the LED, otherwise turn it off.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY