THis was a tutorial using red, green, and blue led's to blend color and create violet, yellow, and turquiose and have all of these colors blink on and off.
Code:
int redPin = 12; // Red LED connected to digital pin 12
int greenPin = 11; // Green LED connected to digital pin 11
int bluePin= 10; // Blue LED connected to digital pin 10
void setup() // run once, when the sketch starts
{
pinMode(redPin, OUTPUT); // sets the digital pin as output
pinMode(greenPin, OUTPUT); // sets the digital pin as output
pinMode(bluePin, OUTPUT); // sets the digital pin as output
}
void loop() // run over and over again
{
digitalWrite(redPin, HIGH); // sets the Red LED on
digitalWrite(greenPin, LOW); // sets the Green LED off
digitalWrite(bluePin, LOW); // sets the Blue LED off
delay(2000); // waits for half a second
digitalWrite(redPin, HIGH); // sets the Red LED on
digitalWrite(greenPin, HIGH); // sets the Green LED on
digitalWrite(bluePin, LOW); // sets the Blue LED off
delay(2000); // waits for half a second
digitalWrite(redPin, LOW); // sets the Red LED off
digitalWrite(greenPin, HIGH); // sets the Green LED on
digitalWrite(bluePin, LOW); // sets the Blue LED off
delay(2000); // waits for half a second
digitalWrite(redPin, LOW); // sets the Red LED off
digitalWrite(greenPin, HIGH); // sets the Green LED on
digitalWrite(bluePin, HIGH); // sets the Blue LED on
delay(2000); // waits for half a second
digitalWrite(redPin, LOW); // sets the Red LED off
digitalWrite(greenPin, HIGH); // sets the Green LED on
digitalWrite(bluePin, HIGH); // sets the Blue LED on
delay(2000); // waits for half a second
digitalWrite(redPin, LOW); // sets the Red LED off
digitalWrite(greenPin, LOW); // sets the Green LED off
digitalWrite(bluePin, HIGH); // sets the Blue LED on
delay(2000); // waits for half a second
digitalWrite(redPin, HIGH); // sets the Red LED on
digitalWrite(greenPin, LOW); // sets the Green LED off
digitalWrite(bluePin, HIGH); // sets the Blue LED on
delay(2000); // waits for half a second
}
So do you just plug in LEDs to the specified pins or is there any more circuitry?
bibblebob2008 2 years ago
Hey this is awesome, also-I love you for including the code. I'm switching over from a BASIC stamp to an Arduino and I need to learn the new language. Thanks!
wafrus 3 years ago