1. /* 2. DC Voltmeter 3. Arduino DVM based on A-D voltage divider 4. ZS6KMD 5. */ 6. #include 7. LiquidCrystal lcd(7, 8, 9, 10, 11, 12); 8. int analogInput = 0; 9. float vout = 0.0; 10. float vin = 0.0; 11. float R1 = 100000.0; // resistance of R1 (100K) NOTE -see text! 12. float R2 = 10000.0; // resistance of R2 (10K) NOTE - see text! 13. int value = 0; 14. void setup(){ 15. pinMode(analogInput, INPUT); 16. lcd.begin(16, 2); 17. lcd.print("DC VOLTMETER"); 18. } 19. void loop(){ 20. // read the value at analog input 21. value = analogRead(analogInput); 22. vout = (value * 5.0) / 1024.0; // NOTE - see text 23. vin = vout / (R2/(R1+R2)); 24. if (vin<0.09) { 25. vin=0.0;//statement to limit any undesired reading 26. } 27. lcd.setCursor(0, 1); 28. lcd.print("INPUT V= "); 29. lcd.print(vin); 30. delay(500); 31. }