arduino analog pins

can I use analog pin 4 and 5 for using as input of photo diodes? because right now it doesn't seems to work or its me who doing something wrong [u]Arduino uno[/u]

And the sketch you are using is ?

Also just to be clear "photo diodes" or "ldr"

Your code got altered by the forum.

See the symbol ( </> ) use that so we can see it properly.
See you tried but you need to maybe try again so we can get rid of the smiley character and any other changes.

What values are you getting out? Write them to serial so you know what it's seeing.

Where is your schematic? Are you sure they're wired right?

DrAzzy: What values are you getting out? Write them to serial so you know what it's seeing.

Where is your schematic? Are you sure they're wired right?

in the "working" inputs when no Infra red light hit them I get about 10 and in the "broken" (a4/a5) about 750

yes I'm sure I connected them right, also rechecked all the components with the working ones and changed even the wires but nothing changed.

also, I tried to change the if(val>550) to 800 but then a5 don't gives a value bigger then 800

A link to the the photo diodes would also be nice to have. And thanks for changing the code tags it makes our lives a lot easier.

I meant where you got yours not a general link LOL Just so the specs can be deduced

lol I don't know I just went to the store and bought them for much more then usuall ( electronic parts is really expensive here for some reason and I don't have time to wait for delivery)

Ballscrewbob: I meant where you got yours not a general link LOL Just so the specs can be deduced

Then start simple.

Going to reference you to HERE

As you can see they mention the very low output of photodiodes and show two methods.

Your best option to make sure each diode is working is the first one shown as it is simple to do and hopefully will give you a reading for each diode. If they don't give enough output then an OP-AMP will be needed for each one used.

As DrAzzy suggested a schematic would be fantastic around now.

Is this an official board, or some clone?

I would do some sanity checks at this point, because something isn’t adding up.

Disconnect the wires from a working pin, and a misbehaving pin. Ensure that the photodiodes connected to both of these pins are seeing approximately equal light, hence the output should be about the same. Measure the voltage on the wire that went to the pins with your multimeter. This will tell you if you have a problem with the wiring and/or photodiodes.

Assuming that they’re getting the same values otherwise, hold down the reset button and measure the resistance between each of those two (unconnected) analog pins and the 5v pin? If not, what do you get?

Assuming you do, let the sketch run, but leave those two analog pins unconnected; put 10k resistor to ground on each pin, and measure the voltages on the pins - They should both read zero.

DrAzzy:
Is this an official board, or some clone?

I would do some sanity checks at this point, because something isn’t adding up.

Disconnect the wires from a working pin, and a misbehaving pin. Ensure that the photodiodes connected to both of these pins are seeing approximately equal light, hence the output should be about the same. Measure the voltage on the wire that went to the pins with your multimeter. This will tell you if you have a problem with the wiring and/or photodiodes.

Assuming that they’re getting the same values otherwise, hold down the reset button and measure the resistance between each of those two (unconnected) analog pins and the 5v pin? If not, what do you get?

Assuming you do, let the sketch run, but leave those two analog pins unconnected; put 10k resistor to ground on each pin, and measure the voltages on the pins - They should both read zero.

I payed like 50$ for the school to buy it for me so I guess its original.
I don’t have multimeter/know how to use it I’m just a dumb student on his last year of school that was asked to make project on Arduino without teaching us anything about Arduino

Christ, $50!? That's more than the official sticker price for an Arduino Uno - if that wasn't for an Uno + kit of parts, they took you for twenty bucks.

Sorting this out will probably require a multimeter, so you should start trying to scare one up - your teacher must have one around; This is a very basic tool, and inexpensive nowadays too. It's the sort of thing that every household should own, frankly - like a hammer, screwdrivers, scissors....

If the operation of the meter is not obvious from the markings, a google search will give you what you need to know.

I suspect the idea was for you to go out and, you know, learn how to do these things.

Technology courses at the highschool level are typically pretty lousy. People who are both good with people as a teacher, and good at (or even interested in) the technical stuff are rare to begin with, and the really talented technical people can easily get a job in industry paying three times what a teacher would get. So it's hardly surprising that you feel like your teacher isn't doing much teaching here. But the good news is that if you can get into a technical mindset and find it interesting, you can teach yourself and enjoy the process.

Wiring in diagram looks correct - the results your seeing don't make sense, as you stated above.

I don't know how I could proceed in sorting this out without a multimeter though.

DrAzzy: Wiring in diagram looks correct - the results your seeing don't make sense, as you stated above.

I don't know how I could proceed in sorting this out without a multimeter though.

thanks for trying to help, I will continue to just try some random stuff hoping it will work, I will update if I get a solution for this

also it was really fun to write the code and see how the things work with the Arduino I'm looking forward to learn this kind of stuff in college or uni where ever I will be accepted

Why not just buy a multimeter?

A cheap one - sufficient for this and general use - is under 20 bucks, and it will tell you which of three potential causes of the behavior you're seeing is going on within literally minutes.

The only other thing I can think of off the top of my head is that you are close to the power limits of the Arduino in some way.

To alleviate that you could power the servo and LCD from another source.

Without a meter you could eliminate the servo and the LCD and rely on serial statements to debug.

Take serial readings BEFORE you remove those items and then take readings AFTER you have removed them and see if there is a definite difference.

I think the problem is that either:

  • His board is a clone that has pullups in place on SDA and SCL on the board - 4.7k ohm ones, to be specific.

  • Somehow the internal pullups are getting enabled (though I would expect more like 200-250)

  • His wiring is messed up or his parts are bad.

  • Actually - I thought of another one just now - he could have mistaken an LED (probably an IR one) for a photodiode (many photodiodes look much like LEDs); At normal operating current, the voltage across an IR LED is like 1.5-1.8v. But with a 10k series resistor, it would be somewhat lower than that, just about right to give a 750 reading on the ADC (1.3ish volt drop across the LED, say...)

Here's something you can do without a meter: What happens if you swap the wire going to A3 and A4 - does the problem move to A3? If yes, there's a problem with the wiring, or the components. If the problem stays with A4, that points to one of the first two issues above (or a straight-up damaged or defective Arduino - but that seems unlikely).

If the problem moved to A3 in above test, swap the suspected photodiode with the one on A4 - does the problem move back to A4? That implies that your photodiode is bad or isn't a photodiode. If not, it's a wiring problem.

DrAzzy: Here's something you can do without a meter: What happens if you swap the wire going to A3 and A4 - does the problem move to A3? If yes, there's a problem with the wiring, or the components. If the problem stays with A4, that points to one of the first two issues above (or a straight-up damaged or defective Arduino - but that seems unlikely).

If the problem moved to A3 in above test, swap the suspected photodiode with the one on A4 - does the problem move back to A4? That implies that your photodiode is bad or isn't a photodiode. If not, it's a wiring problem.

I checked and I'm not mistaken with the components,

my check of values [u]analog pin|without IR light| with IR light[/u] a0 | ~30 | ~980 a1 | ~30 | ~980 a2 | ~30 | ~980 a3 | ~30 | ~980 a4 | ~770 | ~980 a5 | ~770 | ~980

I tested all of the analog pins with the same photo diode and ir light.

also, if its a problem with the Arduino which I think it is, do I need to but new shield/Arduino or just replace the little black thing with a lot of legs on the Arduino itself ATmega328 ( I don't know how it called in English)

Try the test I recommended - switch the wires on, say, A3 and A4, and see whether the problem stays on A4 or moves to A3.