Hello, I'm not sure if anyone out there can help, but if they can, please do. I am an Arduino beginner, and I ordered the Arduino Uno starter kit. When I got the package, I went through the basics, and decided to make the color mixing lamp. I know for sure that the code is correct, and the wiring looks exactly like it does in the picture in the book. I feel like the wiring may not be working, but I am almost one hundred percent sure it is correct. I get no error messages, and my only guess would be that the photoreceptors are not working. The strange thing is, though, if I remove one of them, the LED changes color. Depending on which one I remove, the LED changes a different color. Does anyone have a clue what is going on? If so, I would really appreciate the assistance.
Here is the code:
const int greenLEDPin = 9;
const int redLEDPin = 11;
const int blueLEDPin = 10;
const int redSensorPin = A0;
const int greenSensorPin = A1;
const int blueSensorPin = A2;
int redValue = 0;
int greenValue = 0;
int blueValue = 0;
int redSensorValue = 0;
int greenSensorValue = 0;
int blueSensorValue = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(greenLEDPin,OUTPUT);
pinMode(redLEDPin,OUTPUT);
pinMode(blueLEDPin,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
redSensorValue = analogRead(redSensorPin);
delay(5);
greenSensorValue = analogRead(greenSensorPin);
delay(5);
blueSensorValue = analogRead(blueSensorPin);
Serial.print("Raw Sensor Values \t Red: ");
Serial.print(redSensorValue);
Serial.print("\t Green");
Serial.print(greenSensorValue);
Serial.print("\t Blue");
Serial.println(blueSensorValue);
redValue = redSensorValue/4;
greenValue = greenSensorValue/4;
blueValue = blueSensorValue/4;
Serial.print("Mapped Sensor Values \t Red");
Serial.print(redValue);
Serial.print("\t Green");
Serial.print(greenValue);
Serial.print("\t Blue");
Serial.println(blueValue);
analogWrite(redLEDPin, redValue);
analogWrite(greenLEDPin, greenValue);
analogWrite(blueLEDPin, blueValue);
}
Here is a photo of the board: