Could someone modify this code so that instead of a normal LED, an RGB LED will turn on and blink red, green, blue? For like 1 second per color? Thanks, I'm brand new so treat me like an idiot please
Code:
Could someone modify this code so that instead of a normal LED, an RGB LED will turn on and blink red, green, blue? For like 1 second per color? Thanks, I'm brand new so treat me like an idiot please
Code:
What code ?
When was the assignment given to you ?
This is probably part of the same assignment:
https://forum.arduino.cc/t/help-turning-a-motor/953416
Sorry I forgot the actual code. I edited the message, there you go.
Yes, but did not provide the code. ![]()
Perchance read the instructions for posting?
const byte RedLEDPin = 2;
const byte GreenLEDPin = 3;
const byte BlueLEDPin = 4;
void setup()
{
Serial.begin(115200);
pinMode(RedLEDPin, OUTPUT);
pinMode(GreenLEDPin, OUTPUT);
pinMode(BlueLEDPin, OUTPUT);
}
void loop()
{
int sensorReading = analogRead(A0);
Serial.println(sensorReading);
if (sensorReading >= 1000)
{
digitalWrite(RedLEDPin, HIGH);
delay(1000);
digitalWrite(RedLEDPin, LOW);
digitalWrite(GreenLEDPin, HIGH);
delay(1000);
digitalWrite(GreenLEDPin, LOW);
digitalWrite(BlueLEDPin, HIGH);
delay(1000);
digitalWrite(BlueLEDPin, LOW);
}
delay(500);
}
thank you so much!!!!