Go Down

Topic: Photoreceptor Not Working? (SOLVED (not the way I expected though)) (Read 383 times) previous topic - next topic

cheerfulfangs53

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:

Code: [Select]
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:

Paul_KD7HB

Oh, too bad. My crystal ball refuses to work.

Paul

jremington

Quote
Does anyone have a clue what is going on?
Only if you provide those clues, by reading and following the directions in the "How to use this forum" post.

cheerfulfangs53

I now provided everything the forum asks for, including code and a picture of the current board setup.

jremington

#4
Apr 28, 2018, 12:36 am Last Edit: Apr 28, 2018, 12:45 am by jremington
I can't make sense out of the fuzzy, too small photo.
 
Please post a hand drawn wiring diagram (not Fritzing), showing component values and how you have connected all the parts.

Also, it would help a great deal if you paid attention to the output from the print statements, before and after putting your hand over a sensor, and before and after removing the sensor.

The print statements are there to give you information about what the program is doing.

Finally, it looks like you used a pin number in the following statement because you earlier made a mistake typing the name "greenLEDPin". It is better to correct spelling errors when the compiler complains.

Code: [Select]
  analogWrite(9, greenValue);

cheerfulfangs53

I have changed the code the way you told me to, and I tried to put my new image of the Arduino setup in as an attachment, but it wouldn't allow me to. It said that the file format was not supported. I am really sorry that my helpfulness in getting help is not a whole lot, the picture will be up as soon as I can convert it to a new file type. Would a .zip file be okay?

jremington

Quote
Would a .zip file be okay?
No, most people won't open it.

Make a hand drawn wiring diagram instead and post a clear photo of that.

cheerfulfangs53

will you open it is more the question. A hand drawn image, especially a clear one, is not an option.

jremington

#8
May 01, 2018, 10:51 pm Last Edit: May 01, 2018, 10:52 pm by jremington
Quote
A hand drawn image, especially a clear one, is not an option.
Impressive, the difficulties.

Good luck with your project.

cheerfulfangs53

Quote from: jremington link=msg=3713874 date=1525207882
Good luck with your project.
[/quote
If that was supposed to be a nice good luck instead of a sarcastic "see you later, sucker", then thank you. I'll need it.

wvmarle

Well, if you really want help, you have no choice but to provide all the information needed about your project that shows clearly and unambiguously what's going on. Code, a circuit diagram (hand drawn or CAD, whatever you like - I don't see why hand drawn is a problem as you apparently been making and posting photos before though they've disappeared now) and a description of what it does and what you expect it to do are the basics.

A well working crystal ball may also be acceptable. There are more posters like you, that post little to no info, and expect us to know it all. It's be convenient to be able to look into a crystal ball at times as in to fill in all the gaps.

Without that, no help possible. No matter how much we like to help.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up