#include <LiquidCrystal.h>// include the library code
/*************************************************************************/
const int redPin = 11; // R petal on RGB LED module connected to digital pin 11
const int greenPin = 10; // G petal on RGB LED module connected to digital pin 10
const int bluePin = 9; // B petal on RGB LED module connected to digital pin 9
/**********************************************************/
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
/**************************************************************************/
void setup()
{
pinMode(redPin, OUTPUT); // sets the redPin to be an output
pinMode(greenPin, OUTPUT); // sets the greenPin to be an output
pinMode(bluePin, OUTPUT); // sets the bluePin to be an output
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
}
/***************************************************************************/
void loop() // run over and over again
{
// Basic colors:
color(255, 0, 0); // turn the RGB LED red
printToLCD(" Red ");
delay(1000); // delay for 1 second
color(0,255, 0); // turn the RGB LED green
printToLCD(" Green ");
delay(1000); // delay for 1 second
color(0, 0, 255); // turn the RGB LED blue
printToLCD(" Blue ");
delay(1000); // delay for 1 second
// Example blended colors:
color(255,0,252); // turn the RGB LED pink
printToLCD(" Pink ");
delay(1000); // delay for 1 second
color(237,109,0); // turn the RGB LED orange
printToLCD(" Orange ");
delay(1000); // delay for 1 second
color(255,215,0); // turn the RGB LED yellow
printToLCD(" Yellow ");
delay(1000); // delay for 1 second
color(34,139,34); // turn the RGB LED green
printToLCD(" Green ");
delay(1000); // delay for 1 second
color(0,112,255); // turn the RGB LED blue
printToLCD(" Blue ");
delay(1000); // delay for 1 second
color(0,46,90); // turn the RGB LED indigo
printToLCD(" Indigo ");
delay(1000); // delay for 1 second
color(128,0,128); // turn the RGB LED purple
printToLCD(" Purple ");
delay(1000); // delay for 1 second
}
/******************************************************/
void color (unsigned char red, unsigned char green, unsigned char blue)// the color generating function
{
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
/******************************************************/
void printToLCD(const char* text) {
lcd.clear();
for ( int i = 0; i < 15; i++)
{
lcd.setCursor(i,0); // set the cursor to column 15, line 0
lcd.print(text[i]); // Print a message to the LCD.
}
}