I made a volt meter!

using the arduino board to measure voltage
All I have is a jumper wire poked into the analog pin 0 receptacle. At samples 3 and 4 I have touched the end of the wire, bringing the voltage to ground. Pretty exciting! The code is below.
I’m working towards building my lightning detector. I have a simple coherer, but haven’t gotten to see if it actually works yet.
// a simple volt meter // version 0.1 float Vref = 5; // volts int Rate = 1; // hz int del = 1/Rate * 1000; // sample rate, ms int vpin = 0; // which pin should be used to measure the voltage // make sure you connect the arduino system ground to the same // as the measurement system int val_adc = 0; // adc counts float val_volts = 0; // volts int i = 0; void setup() { Serial.begin(9600); Serial.print("delay between samples is "); Serial.print(del); Serial.println(" ms"); } void loop() { delay(del); val_adc = analogRead(vpin); val_volts = Vref * (float(val_adc) / 1023); Serial.print(i); Serial.print(": adc reads "); Serial.print(val_adc); Serial.print(" counts = "); Serial.print(val_volts); Serial.println(" volts."); i++; if (i >= 10) { i = 0; } }
Advertisement