Go Down

Topic: Quick question on analogread and write resolution. (Read 677 times) previous topic - next topic

leakedazaz

I'm using a Due and was wonder if I only need to set the resolutions once in the set up or every time before i use the read or write command. The example on this website did it before every write command.

tammytam

#1
Jun 24, 2015, 02:28 pm Last Edit: Jun 24, 2015, 03:41 pm by tammytam
Can you link the example?

analogRead() returns a value between 0 and 1023, so that is your resolution.

analogWrite() takes a value between 0-255.

*Edit: Sorry leak, just read about the Dues ability to set the resolution. And the honest answer is I don't know without getting a scope on it.

MorganS

You only need to set it once in setup(), unless you are changing it in the middle of your program, which would be a bad idea.

Which website? Your link is missing.
"The problem is in the code you didn't post."

MarkT

You change it whenever you want, as often as you want as far as I know, it will then
apply to subsequent analogRead() and analogWrite() calls.  Why wouldn't it?  Internally
I think everything is done with 12 bit resolution, just the arguments and results of
calls to analogWrite and analogRead are shifted to match.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up