/* Arduino Measures Current from Constant Current Source https://www.bristolwatch.com/ele4/ccs_lm358.htm by Lewis Loflin lewis@bvu.net also see: Arduino Controlled Power Constant Current Source http://www.sullivan-county.com/ele/ard_css.htm */ // Arduino code: #include #include LiquidCrystal_I2C lcd(0x27, 16, 2); //set the LCD address to 0x27 //for a 16 chars and 2 line display #define pwmPin 9 #define pot 0 #define analog1 1 int analogValue = 0; // variable to hold the analog value int total, average; float volts; void setup() { // open the serial port at 9600 bps: Serial.begin(9600); lcd.init(); lcd.backlight(); } void loop() { // read the analog input on pin 0: analogValue = analogRead(0) ; Serial.print("Pot value = "); Serial.print(analogValue); Serial.print("\n"); analogWrite(pwmPin, analogValue / 4); analogValue = analogRead(pot); lcd.setCursor(0, 0); lcd.print("POT = "); lcd.setCursor(6, 0); lcd.print(analogValue); analogValue = analogRead(analog1); lcd.setCursor(0, 1); lcd.print("AMPs = "); lcd.setCursor(11, 1); lcd.print(analogValue * .00467 ); Serial.print("AMPs = "); Serial.print(analogValue * .00475); Serial.print("\n"); delay(500); }