//LED Code for Uno
const int analogPin = A0;//the analog input pin attach to analog pin A0
const int LEDRed = 11;//the led attach to pin 9
const int LEDGreen = 13;
const int LEDBlue = 12;
int inputValue = 0;//variable to store the value coming from sensor
int outputValue = 0;//variable to store the output value
const int analogPin2 = A1;//the analog input pin attach to analog pin A0
const int LEDRed2 = 8;//the led attach to pin 9
const int LEDGreen2 = 10;
const int LEDBlue2 = 9;
int inputValue2 = 0;//variable to store the value coming from sensor
int outputValue2 = 0;//variable to store the output value
const int analogPin3 = A2;//the analog input pin attach to analog pin A0
const int LEDRed3 = 5;//the led attach to pin 9
const int LEDGreen3= 7;
const int LEDBlue3 = 6;
int inputValue3 = 0;//variable to store the value coming from sensor
int outputValue3 = 0;//variable to store the output value
const int analogPin4 = A3;//the analog input pin attach to analog pin A0
const int LEDRed4 = 2;//the led attach to pin 9
const int LEDGreen4 = 4;
const int LEDBlue4 = 3;
int inputValue4 = 0;//variable to store the value coming from sensor
int outputValue4 = 0;//variable to store the output value
void setup(){
Serial.begin(9600);
pinMode(LEDRed,OUTPUT);
pinMode(LEDGreen,OUTPUT);
pinMode(LEDBlue,OUTPUT);
pinMode(LEDRed2,OUTPUT);
pinMode(LEDGreen2,OUTPUT);
pinMode(LEDBlue2,OUTPUT);
pinMode(LEDRed3,OUTPUT);
pinMode(LEDGreen3,OUTPUT);
pinMode(LEDBlue3,OUTPUT);
pinMode(LEDRed4,OUTPUT);
pinMode(LEDGreen4,OUTPUT);
pinMode(LEDBlue4,OUTPUT);
}
void loop(){
/////////////1//////////////
inputValue = analogRead(analogPin);//read the value from the sensor
outputValue = map(inputValue,0,1023,0,255);//Convert from 0-1023 proportional to the number of a number of from 0 to 255
if (outputValue < 100) //red
{
analogWrite(LEDRed,255);
analogWrite(LEDGreen,0);
analogWrite(LEDBlue,0);
}
else if (outputValue < 110)//red orange
{
analogWrite(LEDRed,255);
analogWrite(LEDGreen,60);
analogWrite(LEDBlue,0);
}
else if (outputValue < 120)//orange
{
analogWrite(LEDRed,255);
analogWrite(LEDGreen,123);
analogWrite(LEDBlue,0);
}
else if (outputValue < 130)//orange yellow
{
analogWrite(LEDRed,255);
analogWrite(LEDGreen,180);
analogWrite(LEDBlue,0);
}
else if (outputValue < 140)//yellow
{
analogWrite(LEDRed,255);
analogWrite(LEDGreen,246);
analogWrite(LEDBlue,0);
}
else if (outputValue < 150)//yellow green
{
analogWrite(LEDRed,220);
analogWrite(LEDGreen,244);
analogWrite(LEDBlue,66);
}
else if (outputValue < 160)//green
{
analogWrite(LEDRed,0);
analogWrite(LEDGreen,255);
analogWrite(LEDBlue,0);
}
else if (outputValue < 170)//green blue
{
analogWrite(LEDRed,66);
analogWrite(LEDGreen,244);
analogWrite(LEDBlue,161);
}
else if (outputValue < 180)//blue
{
analogWrite(LEDRed,0);
analogWrite(LEDGreen,255);
analogWrite(LEDBlue,250);
}
else if (outputValue < 190)//blue cyan
{
analogWrite(LEDRed,66);
analogWrite(LEDGreen,164);
analogWrite(LEDBlue,244);
}
else if (outputValue < 200)//cyan
{
analogWrite(LEDRed,0);
analogWrite(LEDGreen,0);
analogWrite(LEDBlue,255);
}
else if (outputValue < 210)//cyan purple
{
analogWrite(LEDRed,140);
analogWrite(LEDGreen,66);
analogWrite(LEDBlue,255);
}
else if (outputValue < 220)//purple
{
analogWrite(LEDRed,182);
analogWrite(LEDGreen,0);
analogWrite(LEDBlue,255);
}
else if (outputValue < 230)//pink purple
{
analogWrite(LEDRed,219);
analogWrite(LEDGreen,0);
analogWrite(LEDBlue,225);
}
else if (outputValue < 240)//pink
{
analogWrite(LEDRed,255);
analogWrite(LEDGreen,0);
analogWrite(LEDBlue,208);
}
/////////////2//////////////
inputValue2 = analogRead(analogPin2);//read the value from the sensor
outputValue2 = map(inputValue2,0,1023,0,255);//Convert from 0-1023 proportional to the number of a number of from 0 to 255
if (outputValue2 < 100) //red
{
analogWrite(LEDRed2,255);
analogWrite(LEDGreen2,0);
analogWrite(LEDBlue2,0);
}
else if (outputValue2 < 110)//red orange
{
analogWrite(LEDRed2,255);
analogWrite(LEDGreen2,60);
analogWrite(LEDBlue2,0);
}
else if (outputValue2 < 120)//orange
{
analogWrite(LEDRed2,255);
analogWrite(LEDGreen2,123);
analogWrite(LEDBlue2,0);
}
else if (outputValue2 < 130)//orange yellow
{
analogWrite(LEDRed2,255);
analogWrite(LEDGreen2,180);
analogWrite(LEDBlue2,0);
}
else if (outputValue2 < 140)//yellow
{
analogWrite(LEDRed2,255);
analogWrite(LEDGreen2,246);
analogWrite(LEDBlue2,0);
}
else if (outputValue2 < 150)//yellow green
{
analogWrite(LEDRed2,220);
analogWrite(LEDGreen2,244);
analogWrite(LEDBlue2,66);
}
else if (outputValue2 < 160)//green
{
analogWrite(LEDRed2,0);
analogWrite(LEDGreen2,255);
analogWrite(LEDBlue2,0);
}
else if (outputValue2 < 170)//green blue
{
analogWrite(LEDRed2,66);
analogWrite(LEDGreen2,244);
analogWrite(LEDBlue2,161);
}
else if (outputValue2 < 180)//blue
{
analogWrite(LEDRed2,0);
analogWrite(LEDGreen2,255);
analogWrite(LEDBlue2,250);
}
else if (outputValue2 < 190)//blue cyan
{
analogWrite(LEDRed2,66);
analogWrite(LEDGreen2,164);
analogWrite(LEDBlue2,244);
}
else if (outputValue2 < 200)//cyan
{
analogWrite(LEDRed2,0);
analogWrite(LEDGreen2,0);
analogWrite(LEDBlue2,255);
}
else if (outputValue2 < 210)//cyan purple
{
analogWrite(LEDRed2,140);
analogWrite(LEDGreen2,66);
analogWrite(LEDBlue2,255);
}
else if (outputValue2 < 220)//purple
{
analogWrite(LEDRed2,182);
analogWrite(LEDGreen2,0);
analogWrite(LEDBlue2,255);
}
else if (outputValue2 < 230)//pink purple
{
analogWrite(LEDRed2,219);
analogWrite(LEDGreen2,0);
analogWrite(LEDBlue2,225);
}
else if (outputValue2 < 240)//pink
{
analogWrite(LEDRed2,255);
analogWrite(LEDGreen2,0);
analogWrite(LEDBlue2,208);
}
/////////////3//////////////
inputValue3 = analogRead(analogPin3);//read the value from the sensor
outputValue3 = map(inputValue3,0,1023,0,255);//Convert from 0-1023 proportional to the number of a number of from 0 to 255
if (outputValue3 < 100) //red
{
analogWrite(LEDRed3,255);
analogWrite(LEDGreen3,0);
analogWrite(LEDBlue3,0);
}
else if (outputValue3 < 110)//red orange
{
analogWrite(LEDRed3,255);
analogWrite(LEDGreen3,60);
analogWrite(LEDBlue3,0);
}
else if (outputValue3 < 120)//orange
{
analogWrite(LEDRed3,255);
analogWrite(LEDGreen3,123);
analogWrite(LEDBlue3,0);
}
else if (outputValue3 < 130)//orange yellow
{
analogWrite(LEDRed3,255);
analogWrite(LEDGreen3,180);
analogWrite(LEDBlue3,0);
}
else if (outputValue3 < 140)//yellow
{
analogWrite(LEDRed3,255);
analogWrite(LEDGreen3,246);
analogWrite(LEDBlue3,0);
}
else if (outputValue3 < 150)//yellow green
{
analogWrite(LEDRed3,220);
analogWrite(LEDGreen3,244);
analogWrite(LEDBlue3,66);
}
else if (outputValue3 < 160)//green
{
analogWrite(LEDRed3,0);
analogWrite(LEDGreen3,255);
analogWrite(LEDBlue3,0);
}
else if (outputValue3 < 170)//green blue
{
analogWrite(LEDRed3,66);
analogWrite(LEDGreen3,244);
analogWrite(LEDBlue3,161);
}
else if (outputValue3 < 180)//blue
{
analogWrite(LEDRed3,0);
analogWrite(LEDGreen3,255);
analogWrite(LEDBlue3,250);
}
else if (outputValue3 < 190)//blue cyan
{
analogWrite(LEDRed3,66);
analogWrite(LEDGreen3,164);
analogWrite(LEDBlue3,244);
}
else if (outputValue3 < 200)//cyan
{
analogWrite(LEDRed3,0);
analogWrite(LEDGreen3,0);
analogWrite(LEDBlue3,255);
}
else if (outputValue3 < 210)//cyan purple
{
analogWrite(LEDRed3,140);
analogWrite(LEDGreen3,66);
analogWrite(LEDBlue3,255);
}
else if (outputValue3 < 220)//purple
{
analogWrite(LEDRed3,182);
analogWrite(LEDGreen3,0);
analogWrite(LEDBlue3,255);
}
else if (outputValue3 < 230)//pink purple
{
analogWrite(LEDRed3,219);
analogWrite(LEDGreen3,0);
analogWrite(LEDBlue3,225);
}
else if (outputValue3 < 240)//pink
{
analogWrite(LEDRed3,255);
analogWrite(LEDGreen3,0);
analogWrite(LEDBlue3,208);
}
/////////////4//////////////
inputValue4 = analogRead(analogPin4);//read the value from the sensor
outputValue4 = map(inputValue4,0,1023,0,255);//Convert from 0-1023 proportional to the number of a number of from 0 to 255
if (outputValue4 < 100) //red
{
analogWrite(LEDRed4,255);
analogWrite(LEDGreen4,0);
analogWrite(LEDBlue4,0);
}
else if (outputValue4 < 110)//red orange
{
analogWrite(LEDRed4,255);
analogWrite(LEDGreen4,60);
analogWrite(LEDBlue4,0);
}
else if (outputValue4 < 120)//orange
{
analogWrite(LEDRed4,255);
analogWrite(LEDGreen4,123);
analogWrite(LEDBlue4,0);
}
else if (outputValue4 < 130)//orange yellow
{
analogWrite(LEDRed4,255);
analogWrite(LEDGreen4,180);
analogWrite(LEDBlue4,0);
}
else if (outputValue4 < 140)//yellow
{
analogWrite(LEDRed4,255);
analogWrite(LEDGreen4,246);
analogWrite(LEDBlue4,0);
}
else if (outputValue4 < 150)//yellow green
{
analogWrite(LEDRed4,220);
analogWrite(LEDGreen4,244);
analogWrite(LEDBlue4,66);
}
else if (outputValue4 < 160)//green
{
analogWrite(LEDRed4,0);
analogWrite(LEDGreen4,255);
analogWrite(LEDBlue4,0);
}
else if (outputValue4 < 170)//green blue
{
analogWrite(LEDRed4,66);
analogWrite(LEDGreen4,244);
analogWrite(LEDBlue4,161);
}
else if (outputValue4 < 180)//blue
{
analogWrite(LEDRed4,0);
analogWrite(LEDGreen4,255);
analogWrite(LEDBlue4,250);
}
else if (outputValue4 < 190)//blue cyan
{
analogWrite(LEDRed4,66);
analogWrite(LEDGreen4,164);
analogWrite(LEDBlue4,244);
}
else if (outputValue4 < 200)//cyan
{
analogWrite(LEDRed4,0);
analogWrite(LEDGreen4,0);
analogWrite(LEDBlue4,255);
}
else if (outputValue4 < 210)//cyan purple
{
analogWrite(LEDRed4,140);
analogWrite(LEDGreen4,66);
analogWrite(LEDBlue4,255);
}
else if (outputValue4 < 220)//purple
{
analogWrite(LEDRed4,182);
analogWrite(LEDGreen4,0);
analogWrite(LEDBlue4,255);
}
else if (outputValue4 < 230)//pink purple
{
analogWrite(LEDRed4,219);
analogWrite(LEDGreen4,0);
analogWrite(LEDBlue4,225);
}
else if (outputValue4 < 240)//pink
{
analogWrite(LEDRed4,255);
analogWrite(LEDGreen4,0);
analogWrite(LEDBlue4,208);
}
}
Por favor inicie sesión o regístrese para comentar.