I'm working on a project that has 3 RGB LEDs. I want to make a simple method that I can call to control the LEDs for example:
showColor(left, 255, 0, 50);
Which would light up the left LED at 100% red, 0% green, and 20% blue. The code I have running for the method is:
void showColor(int ledPosition, int redIntensity, int blueIntensity, int greenIntensity)
{
if (ledPosition == left)
{
analogWrite (redPin1, redIntesity);
analogWrite (greenPin1, greenIntesity);
analogWrite (bluePin1, blueIntesity);
}
else if (ledPosition == middle)
{
analogWrite (redPin2, redIntesity);
analogWrite (greenPin2, greenIntesity);
analogWrite (bluePin2, blueIntesity);
}
else if (ledPosition == right)
{
analogWrite (redPin3, redIntesity);
analogWrite (greenPin3, greenIntesity);
analogWrite (bluePin3, blueIntesity);
}
else if (ledPosition == all)
{
for (int index=0, index < 3 ; index++)
{
analogWrite (redPins[index], redIntensity);
analogWrite (greenPins[index], greenIntensity);
analogWrite (bluePins[index], blueIntensity);
}
}
}
I'm getting tons of errors, like that all of the Intensity variables are not declared and that left, right, all, and middle are not declared. I don't know if this is possible, or what I'm doing wrong. I think I've seen something like this before somewhere else, and I don't want to just use 1 variable to control everything. An answer would be greatly appreciated!