Using \"Serial Monitor\" on Energia: 3.) Use the RGB calculator as guide as well
ID: 3846672 • Letter: U
Question
Using "Serial Monitor" on Energia:3.) Use the RGB calculator as guide as well as the Arduino Serial Event example for your program. In the example given to you, you had to used the buttons to change the light intensity. Here, what we want you to do, is just take a string input from the “Serial Monitor” to control your LEDs. In the simplest form you must type “R###G###B###” where ### is from 0 to 255 to set any color, when send is press it sets the color and displays this result on the “Serial Monitor.”
Finally, demo this to your TA on your own computer and own TIVA, have the RGB calculator open as well for easy demoing comparison. Have 2 of the 3 colors hooked up to your MyDAQ oscope so you and your TA can see the PWM changing as you send different values via the “Serial Monitor” (make sure its triggering, also make sure to AI0- hooked to AI1- and finally to TIVA GND). Using "Serial Monitor" on Energia:
3.) Use the RGB calculator as guide as well as the Arduino Serial Event example for your program. In the example given to you, you had to used the buttons to change the light intensity. Here, what we want you to do, is just take a string input from the “Serial Monitor” to control your LEDs. In the simplest form you must type “R###G###B###” where ### is from 0 to 255 to set any color, when send is press it sets the color and displays this result on the “Serial Monitor.”
Finally, demo this to your TA on your own computer and own TIVA, have the RGB calculator open as well for easy demoing comparison. Have 2 of the 3 colors hooked up to your MyDAQ oscope so you and your TA can see the PWM changing as you send different values via the “Serial Monitor” (make sure its triggering, also make sure to AI0- hooked to AI1- and finally to TIVA GND).
3.) Use the RGB calculator as guide as well as the Arduino Serial Event example for your program. In the example given to you, you had to used the buttons to change the light intensity. Here, what we want you to do, is just take a string input from the “Serial Monitor” to control your LEDs. In the simplest form you must type “R###G###B###” where ### is from 0 to 255 to set any color, when send is press it sets the color and displays this result on the “Serial Monitor.”
Finally, demo this to your TA on your own computer and own TIVA, have the RGB calculator open as well for easy demoing comparison. Have 2 of the 3 colors hooked up to your MyDAQ oscope so you and your TA can see the PWM changing as you send different values via the “Serial Monitor” (make sure its triggering, also make sure to AI0- hooked to AI1- and finally to TIVA GND). 3.) Use the RGB calculator as guide as well as the Arduino Serial Event example for your program. In the example given to you, you had to used the buttons to change the light intensity. Here, what we want you to do, is just take a string input from the “Serial Monitor” to control your LEDs. In the simplest form you must type “R###G###B###” where ### is from 0 to 255 to set any color, when send is press it sets the color and displays this result on the “Serial Monitor.”
Finally, demo this to your TA on your own computer and own TIVA, have the RGB calculator open as well for easy demoing comparison. Have 2 of the 3 colors hooked up to your MyDAQ oscope so you and your TA can see the PWM changing as you send different values via the “Serial Monitor” (make sure its triggering, also make sure to AI0- hooked to AI1- and finally to TIVA GND).
Explanation / Answer
Code:
const int redPin = 1;
const int greenPin = 2;
const int bluePin = 3;
void ()
{
Serial.begin(9600);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop()
{
while (Serial.available() > 0)
{
int red = Serial.parseInt();
int green = Serial.parseInt();
int blue = Serial.parseInt();
if (Serial.read() == ' ')
{
red = 255 - constrain(red, 0, 255);
green = 255 - constrain(green, 0, 255);
blue = 255 - constrain(blue, 0, 255);
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
Serial.print(red, HEX);
Serial.print(green, HEX);
Serial.println(blue, HEX);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.