Hey guys,
I am trying to make a DC ammeter and voltmeter using a current and voltage sensor. I used the voltage sensor and it works perfectly. I added a few lines for the current sensor but now it does not work and gives me an error. I have attached the code below. Please help if you can.
/*
DC Voltmeter & Ammeter
*/
int voltageInput = 5;
int currentInput = 0;
float vout = 0.0;
float vin = 0.0;
float R1 = 30000.0; // resistance of R1 (100K)
float R2 = 7500.0; // resistance of R2 (10K)
int voltageValue = 0;
int currentValue = 0;
void setup()
{
pinMode(voltageInput, INPUT);
pinMode(currentInput, INPUT);
Serial.begin(9600);
Serial.print(“DC MULTIMETER”);
}
void loop()
{
// read the value at analog input
voltageValue = analogRead(voltageInput);
vout = (voltageValue * 5.0) / 1024.0; // see text
vin = vout / (R2/(R1+R2));
if (vin<0.09) //statement to quash undesired reading !
{
vin=0.0;
}
currentValue = analogRead(currentInput); // read analog input pin 0
}
Serial.print("INPUT V = ");
Serial.println(vin,2);
Serial.print(currentValue);
Serial.println(“mA”);
}
I get these errors
Analog_input_read:37: error: ‘Serial’ does not name a type
Analog_input_read:38: error: ‘Serial’ does not name a type
Analog_input_read:39: error: ‘Serial’ does not name a type
Analog_input_read:40: error: ‘Serial’ does not name a type
Analog_input_read:42: error: expected declaration before ‘}’ token
‘Serial’ does not name a type