I have successfully made a voltage measurement circuit on my Teensy 3.1 that reads a voltage coming out of digital pin 0 set high and coming back into an analog pin A0 to read voltage.
Basically:
int timer = 100;
int ColA = 0;
int Output;
// Setting digital pin functions
void setup()
{
Serial.begin(38400);
pinMode(0, OUTPUT);
}
// Program
void loop()
{
digitalWrite(0, HIGH);
delay(timer);
Output = analogRead(A0);
Serial.println(Output);
delay(timer);
}
It works fine with my circuit on a Teensy 3.1 running 3.3v however when i run this code on an Arduino Uno running 5v wired exactly the same way I just get this print out of numbers that cycles back and forth from ~128 down to 0 and back constantly.
Any insight on the differences here would be great. I need the 5v micro-controller to run a 4051 multiplexer!
digitalWrite
from the loop and put it in setup? And do you have an oscilloscope? That'll tell you what electrickery is happening.