Hello all,
I'm having trouble running code for a current sensor. The error Im getting is 'missing terminating character'
at first the error was highlighting the line
'Serial.println((counts * vpp) * 1000);'
now it is referencing the next line
'Serial.print(Pre_Amp (mV): ");'
const float vpp = 0.0048828125;
const float apmv = .2666666666667;
int counts;
void setup() {
// put your setup code here, to run once:
pinMode(6, OUTPUT);
Serial.begin(115200);
}
void loop() {
digitalWrite(6, HIGH);
// digitalWrite(5, HIGH);
delay(3000);
digitalWrite(6, LOW);
// digitalWrite(5,LOW);
delay(1000);
// put your main code here, to run repeatedly:
Serial.println("- - - - - - - -");
counts = analogRead(A1);
Serial.print("Counts: ");
Serial.println(counts);
Serial.print("Post_Amp (mV): ");
Serial.println((counts * vpp) * 1000);
Serial.print(Pre_Amp (mV): ");
Serial.println((counts * vpp) / 20) *1000);
Serial.print("Amps (A): ");
Serial.println(((counts * vpp) / 20) * 1000) * apmv);
delay(100);
}
The goal of the code is to convert volts and amps from a current shunt and output specs. I referenced this code from the youtube video:
TUTORIAL: How to Measure Current - Arduino - Current Shunt & Amplifier (Part 2 - Wireup & Code)
code displayed at 9:42

