0

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!

asked Oct 10, 2015 at 7:16
1
  • What happens if your remove the digitalWrite from the loop and put it in setup? And do you have an oscilloscope? That'll tell you what electrickery is happening. Commented Oct 10, 2015 at 7:38

1 Answer 1

1

If you're still using D0 as your output on the Uno then yes you are doomed to failure.

D0 and D1 are the serial port. You are using that to communicate with the PC. You cannot use them for any other purpose at the same time.

Pick a different IO pin to be your voltage source.

answered Oct 10, 2015 at 11:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.