Objective: Use an analogRead function to input a signal from a photoresistor, and digital. Write function to create different colors from a RGB LED.
Project: As the photoresistor detects increasing light levels (according to the table below) the RGB LED will change colors. The RGB (Red Green Blue) LED is actually 3 different colored LEDs packaged into a single body. By lighting different combinations of the three colored LEDs, different colors can be created. The table below shows what LED color combinations will create, as well as the desired photoresistor readings:
Example Code:
Below is a portion of the code that would be used in the program described above. It would be in the function void loop()
if (sensorReading>920)
{
//display white
}
else if(sensorReading>900)
{
//display yellow
}
else if(sensorReading>850)
{
//display red
}
else if(sensorReading>800)
{
//display purple
}
else if(sensorReading>750)
{
//display blue
}
else if(sensorReading>600)
{
//display teal
}
else if(sensorReading>450)
{
//display green
}
else
{
5/3/2020 Project 10
https://murraystate.instructure.com/courses/1359835/assignments/5892388?module_item_id=13755093 2/2
//off
}
Essay
Reviews
Contact
Copyright © 2019 HomeworkMarket.com
Recent Comments