I'm stuck on a really simple thing but you have maybe a response...
I want to read voltage from external power supply greater than 5V (it's a 12V DC transformer). I use a voltage divider to get voltage between 0-5v (with 4 1K resistors). With my multimeter the value is stable in entry (2.80V approximatively after 3 first resistors for 11.80V in DC input).
But the value from A0 analog input fluctuate from 0 to 900 without interruption (via intermediate values). I don't know why? Wrong signal from DC transfomer ? My arduino uno is powered by USB.
There is either something wrong with your "DC transformer" or with one or both of your connections to the Arduino or with the code that you did not show us.
By the way, your "DC transformer" is actually a "DC power supply". DC and transformers do not go well together.
Thanks for your responses.
My DC power supply is battery charger for motorcycle (see linked picture). The final power supply of my project will be realized by a car battery. Will these disruptions also occur? Do I have a way to filter that?
Are you measuring the voltage WITH batteries attached or WITHOUT?
Chargers for batteries can have something called a "trickle charger" (Don't know the real english word for it though, could be wrong). What this basicaly means is that the output voltage will sometimes drop to reactivate the battery for a short time, then charging it again. Cheap chargers can throw some issues in the mix when badly designed.
Also, if you really want to charge a 12V battery you need more than 12V, usually with 14.2V or 14.4V depending on the battery.
C-F-K:
Chargers for batteries can have something called a "trickle charger" (Don't know the real english word for it though, could be wrong). What this basicaly means is that the output voltage will sometimes drop to reactivate the battery for a short time, then charging it again.
In other words: your sketch is quite possibly working perfectly fine. The issue is that you are mistaken about what to expect. Try attaching your thingumajig to an oscilloscope rather than a multimeter.