0

I want to get a low voltage on output pin of Arduino mega. I have connected Pin 46 to A3, and wrote 120 value to 46 port. Expected was to get 2-3v on A3 input pin. Instead I always get 1023 values as input. Am I doing something wrong ?

void setup(){
 Serial.begin(9600);
 pinMode(46, OUTPUT);
 pinMode(A3,INPUT);
 }
void loop(){
 analogWrite(46,120);
 Serial.println(analogRead(A3));
 }
Nick Gammon
38.9k13 gold badges69 silver badges125 bronze badges
asked Sep 20, 2015 at 20:41
1
  • You could substitute an Arduino Due and connect to pin DAC1 or DAC2 (located between A11 and CANRX), 12-bit-resolution DAC's :) Commented Sep 20, 2015 at 21:49

1 Answer 1

1

The analog outputs aren't real analog outputs, they are PWM.

That means that they rapidly switch from OFF to ON and back to OFF again. The analog value is the ration of OFF time to ON time, known as the Duty Cycle.

You can convert that rapid switching to a real voltage by passing the signal through a low pass filter. The simplest form is the RC filter:

enter image description here

answered Sep 20, 2015 at 21:09

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.