// voltmeter sketch in Arduino
// implemented on chipKIT UNO32 Microcontroller
// by: Devin Cohen
// date: 1/16/2013
const int voltagePin = A0; // analog input
const int maxDigital = 1024; // 10 bit ADC
const int delayTime = 100; // milliseconds
int adcValue;
const float referenceVoltage = 3.30; // board voltage
float voltage;
void setup() {
pinMode(voltagePin, INPUT);
Serial.begin(9600); // open up usb to serial connection
// "COM4" on my computer, 9600 baud
}
void loop(){
delay(delayTime);
adcValue = analogRead(voltagePin); // read from ADC
voltage = referenceVoltage * adcValue / maxDigital; // converts digital data
// to actual voltage
Serial.print(voltage);
Serial.print(" V\n"); // output to serial
}
""" voltmeter.py
by: Devin Cohen
date: 1/16/2013
uses the pyserial extention
(http://pypi.python.org/pypi/pyserial)"""
import serial
ser = serial.Serial("COM4",9600) """ open serial
connection on COM4, 9600 baud """
while 1:
readin = ser.readline() """ read line
from serial and print it """
print readin