That is not a very strict value, and 22k is still okay. You can compensate that with the average of a few samples.įor a good analog value, the impedance at a analog pin should be 10k or less. That means there is very little current drain from the battery, but the resulting measurement is a little more inaccurate. The numbers 220k and 22k is a high resistor value and less accurate. I guess that wileycat agreed with me and continued with the 220k and 22k that I proposed, or he just wanted to test what happened with those values. Using only solid 5x8 pixels block, each block would be about 6.25% between full and 6v, or close to. My final code will be if it's below 110 then lcd.write("LOW! Replace it!"), else take the range and convert it to 1-100% scale (where 1% is 6v) and display block bar graph on LCD. Incidentally I checked analog pin with my meter, it was about 0.9v on analog pin when I had 9v setting. I did allow several seconds each step (and 10 readings per second), and most of the time the value remained unchanged once I stopped turning the dial and Arduino settled on new value. So roughly 9 value for every 1/2 voltage level via resistor divider. the loop routine runs over and over again forever:ĭelay(100) // delay in between reads for stability initialize serial communication at 9600 bits per second: the setup routine runs once when you press reset: This example code is in the public domain. Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).Īttach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. Reads an analog input on pin 0, prints the result to the Serial Monitor. I did put my multimeter on the 9v supply to verify voltage reading while I changed the level and read the serial monitor. Assuming I wired my Arduino correctly, 220k from 9v source to A0, 22k from A0 to ground, plus a few LEDs + resistors from 9v to ground just to provide load on the power supply. One nice thing about a bench power supply with variable voltage, I can simulate voltage range.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |