Hi,
I've got an Uno board. I'm trying to measure voltage, with the maximum voltage in at 24V. I've got a potential divider set up, with 4 10K resistors as R1 and 1 10K as R2 (for a total of 40K R1). A quick calculation sees that the output to Arduino is 4.8V
My arduino code is set to print the voltage, but instead of holding steady at a specific voltage, it is continuously falling, before jumping up again, as seen here:
Could be several things. First off did you remember to run a wire from the negative terminal of the 24vdc voltage source to a arduino ground wire? That is a requirement.
Posting a drawing of your wiring would be very useful.
Might post your code also, use the # to post it into a code window.
It looks from your breadboard that you might have an off-by-one error in the connection between the third and fourth resistors (counting from the left).
--
The Ruggeduino: compatible with Arduino UNO, 24V operation, all I/O's fused and protected
float value=0; // <-- change float to int
void setup(){
pinMode(A0,INPUT); // <-- no need for setup pin in Analog.
Serial.begin(9600);
}
void loop(){
value=analogRead(A0);
Serial.println(value); // Add ( value, DEC)
delay(500);
}
Here a tip. Use a simple circuit to test your code.
In you case, I will use a small potentiometer, connect one end to +5 and the other end GND, the middle going to the Arduino analog pin ( A0 to A5 ), run the code and expect a vlaue ( 0 to 1023 ) to be print.
If code work, THEN construct the circuit you want to do, test it with out Arduino connected, if reading correct, then connect the Ardiuno and see your results.