Hello everyone!! Welcome to this post on Arduino LED Projects!!
Need a short introduction to what the Arduino is then click on LINK
Check out the breadboard intro right HERE
In this project we’ll tell the Arduino if we want green, red, yellow or blue LED on.
Demo:
So this is what my project looks like:
Things Required:
- Arduino UNO
- LEDs (1 of green, red, yellow and blue each)
- Breadboard
- 220 ohm resistor (x4)
- Jumper Wires
- Arduino IDE on computer
Functions used:
- digitalWrite()
- Serial.println()
- Serial.available()
- Serial.readString()
Reference Material:
I referred to this (LINK) video for this project.
Code:
View/ Download from Github : (LINK)
int greenled= 11;
int redled=10;
int yellowled=9;
int blueled=8;
String msg1= "Do you want green, red, yellow or blue led on?";
String choice;
String msg2=" led is on";
void setup() {
// put your setup code here, to run once:
pinMode(greenled, OUTPUT);
pinMode(redled, OUTPUT);
pinMode(yellowled, OUTPUT);
pinMode(blueled, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(msg1);
while(Serial.available()==0){
}
choice = Serial.readString();
if(choice=="green"){
digitalWrite(greenled, HIGH);
digitalWrite(redled, LOW);
digitalWrite(yellowled, LOW);
digitalWrite(blueled, LOW);
}
if(choice=="red"){
digitalWrite(greenled, LOW);
digitalWrite(redled, HIGH);
digitalWrite(yellowled, LOW);
digitalWrite(blueled, LOW);
}
if(choice=="yellow"){
digitalWrite(greenled, LOW);
digitalWrite(redled, LOW);
digitalWrite(yellowled, HIGH);
digitalWrite(blueled, LOW);
}
if(choice=="blue"){
digitalWrite(greenled, LOW);
digitalWrite(redled, LOW);
digitalWrite(yellowled, LOW);
digitalWrite(blueled, HIGH);
}
}
Stay Tuned for upcoming posts on Arduino Projects! We’re on the basic newbie projects right now and slowly, gradually move on to those cool, ultra techy projects!! Want to be the first to know when a new and amazing post comes up?? Then feel free to subscribe!
Happy Learning!!
