I am using a RGB LED and can get it to light whatever color i want by itself but when I try to program it into this code it doesn't compile. I am trying to get it to light a certain color when the sensor reads a specific value. Thanks in advance for the help.
int speaker = 2;
int led[] = {
9, 10, 11};
int pressure = A1;
const boolean ON = LOW;
const boolean OFF = HIGH;
const boolean RED[] = {
ON, OFF, OFF};
const boolean GREEN[] = {
OFF, ON, OFF};
const boolean BLUE[] = {
OFF, OFF, ON};
const boolean YELLOW[] = {
ON, ON, OFF};
const boolean CYAN[] = {
OFF, ON, ON};
const boolean MAGENTA[] = {
ON, OFF, ON};
const boolean WHITE[] = {
ON, ON, ON};
const boolean BLACK[] = {
OFF, OFF, OFF};
const boolean* COLORS[] = {
RED, GREEN, BLUE, YELLOW, CYAN, MAGENTA, WHITE, BLACK};
void setup() {
Serial.begin(9600);
for(int i = 0; i < 3; i++){
pinMode(led[i], OUTPUT);
}
pinMode(speaker, OUTPUT);
}
void loop() {
int value = analogRead(pressure) / 4;
if((value >= 1) && (value <= 100))
{
setColor(led, GREEN);
digitalWrite(speaker, HIGH);
}
else if(value >= 101)
{
setColor(led, RED);
digitalWrite(speaker, LOW);
}
else
{
setColor(led, CYAN);
digitalWrite(speaker, LOW);
}
Serial.println(value);
delay(100);
}