WP_Post Object ( [ID] => 79 [post_author] => 1 [post_date] => 2013-12-21 13:52:23 [post_date_gmt] => 2013-12-21 13:52:23 [post_content] => This is part of a 37-1 sensor kit, this was a multi-colour LED that was in the kit. NOt much documentation but I wired it up as follows I - GND R - Pin 4 G - Pin 5 B - Pin 6 [caption id="attachment_80" align="alignnone" width="550"] multi color led sensor[/caption] Code Cycle through the LED colours int red = 4; int green = 5; int blue = 6; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(red, OUTPUT); pinMode(green, OUTPUT); pinMode(blue, OUTPUT);pinMode(red, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(red, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(red, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(green, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(green, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second digitalWrite(blue, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(blue, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } Switch them all on at the same time int red = 4; int green = 5; int blue = 6; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(red, OUTPUT); pinMode(green, OUTPUT); pinMode(blue, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(red, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(green, HIGH); // turn the LED on (HIGH is the voltage level) // wait for a second digitalWrite(blue, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(red, LOW); // turn the LED off by making the voltage LOW digitalWrite(green, LOW); // turn the LED off by making the voltage LOW digitalWrite(blue, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } Links Here are links to the sensor kit Ultimate 37 in 1 Sensor Modules Kit for Arduino from Amazon UK Ultimate 37 in 1 Sensor Modules Kit for Arduino from Amazon US [post_title] => Arduino and multi-color LED example [post_excerpt] => [post_status] => publish [comment_status] => closed [ping_status] => open [post_password] => [post_name] => arduino-multi-color-led-example [to_ping] => [pinged] => [post_modified] => 2013-12-21 13:52:23 [post_modified_gmt] => 2013-12-21 13:52:23 [post_content_filtered] => [post_parent] => 0 [guid] => http://www.getmicros.net/?p=79 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw )
This is part of a 37-1 sensor kit, this was a multi-colour LED that was in the kit. NOt much documentation but I wired it up as follows
I – GND
R – Pin 4
G – Pin 5
B – Pin 6
Code
Cycle through the LED colours
int red = 4;
int green = 5;
int blue = 6;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);pinMode(red, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(red, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(red, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
digitalWrite(green, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(green, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
digitalWrite(blue, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(blue, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Switch them all on at the same time
int red = 4;
int green = 5;
int blue = 6;
// the setup routine runs once when you press reset:
void setup()
{
// initialize the digital pin as an output.
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(red, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(green, HIGH); // turn the LED on (HIGH is the voltage level) // wait for a second
digitalWrite(blue, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(red, LOW); // turn the LED off by making the voltage LOW
digitalWrite(green, LOW); // turn the LED off by making the voltage LOW
digitalWrite(blue, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Links
Here are links to the sensor kit
Ultimate 37 in 1 Sensor Modules Kit for Arduino from Amazon UK
Ultimate 37 in 1 Sensor Modules Kit for Arduino from Amazon US