The sketch starts by specifying which pins are going to be used for each of the colors: // Define Pins #define BLUE 3 #define GREEN 5 #define RED 6 The next step is to write the 'setup' function. As we have learnt in earlier lessons, the setup function runs just once after the Arduino has reset. In this case, all it has to do is define the three pins we are using as being outputs. void setup() { pinMode(RED, OUTPUT); pinMode(GREEN, OUTPUT); pinMode(BLUE, OUTPUT); digitalWrite(RED, HIGH); digitalWrite(GREEN, LOW); digitalWrite(BLUE, LOW); } 53/162 Before we take a look at the 'loop' function, let's look at the last function in the sketch. The define variables redValue = 255; // choose a value between 1 and 255 to change the color. greenValue = 0; blueValue = 0; This function takes three arguments, one for the brightness of the red, green and blue LEDs. In each case the number will be in the range 0 to 255, where 0 means off and 255 means maximum brightness. The function then calls 'analogWrite' to set the brightness of each LED.

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
Write a program i C language to make the RGB LED start in the Red color state, then fade to Green, then fade to Blue and finally back to the Red color. Complete the code that is giving in the picture. Remember, the LED should FADE from a color to another. So, make sure that the LED fade.
The sketch starts by specifying which pins are going to be used for each of the colors:
// Define Pins
#define BLUE 3
#define GREEN 5
#define RED 6
The next step is to write the 'setup' function. As we have learnt in earlier lessons,
the setup function runs just once after the Arduino has reset. In this case, all it has
to do is define the three pins we are using as being outputs.
void setup()
{
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
digitalWrite(RED, HIGH);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
}
53/162
Before we take a look at the 'loop' function, let's look at the last function in the
sketch.
The define variables
redValue = 255; // choose a value between 1 and 255 to change the color.
greenValue = 0;
blueValue = 0;
This function takes three arguments, one for the brightness of the red, green
and blue LEDs. In each case the number will be in the range 0 to 255, where 0
means off and 255 means maximum brightness. The function then calls
'analogWrite' to set the brightness of each LED.
Transcribed Image Text:The sketch starts by specifying which pins are going to be used for each of the colors: // Define Pins #define BLUE 3 #define GREEN 5 #define RED 6 The next step is to write the 'setup' function. As we have learnt in earlier lessons, the setup function runs just once after the Arduino has reset. In this case, all it has to do is define the three pins we are using as being outputs. void setup() { pinMode(RED, OUTPUT); pinMode(GREEN, OUTPUT); pinMode(BLUE, OUTPUT); digitalWrite(RED, HIGH); digitalWrite(GREEN, LOW); digitalWrite(BLUE, LOW); } 53/162 Before we take a look at the 'loop' function, let's look at the last function in the sketch. The define variables redValue = 255; // choose a value between 1 and 255 to change the color. greenValue = 0; blueValue = 0; This function takes three arguments, one for the brightness of the red, green and blue LEDs. In each case the number will be in the range 0 to 255, where 0 means off and 255 means maximum brightness. The function then calls 'analogWrite' to set the brightness of each LED.
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