Arduino Forum

Products => Arduino Due => Topic started by: leakedazaz on Jun 24, 2015, 02:18 pm

Title: Quick question on analogread and write resolution.
Post by: leakedazaz on Jun 24, 2015, 02:18 pm
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.
Title: Re: Quick question on analogread and write resolution.
Post by: tammytam on Jun 24, 2015, 02:28 pm
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.
Title: Re: Quick question on analogread and write resolution.
Post by: MorganS on Jun 24, 2015, 07:00 pm
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.
Title: Re: Quick question on analogread and write resolution.
Post by: MarkT on Jun 24, 2015, 11:14 pm
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.