Using straight C for A/D

Hello friends,

I'm trying to use a potentiometer to control the thrust of two rotors. The goal is to use the Arduino Uno to control a hexrotor. Right now we're working on using it to control just two rotors in a demo version. I am accustomed to programming in pure C using AVR Studio, and I'm running into some difficulty using the A/D ports.

I understand that using the "Arduino" language for A/D conversion allows the user to make use of a 5V reference voltage without touching the ADMUX register in the ATMega328P. I would like to use the board's 5V for reference, but I want to avoid using Arduino shorthand. Is there a way to do this?

Yes, of course there's a way to do it - the "Arduino shorthand" is already written in C, and you have the source for it.

When I connect the wire to 5V and run that through my sensor or pot I can get full range analog in while if I wire 3.3V I get less range.

When I do PWM it is 5V pulses.

Of course I am running with 5V Vcc. If I run a slower clock and less voltage, perhaps 3.3V then maybe Vref changes? I never tried....

Of course I am running with 5V Vcc. If I run a slower clock and less voltage, perhaps 3.3V then maybe Vref changes? I never tried....

yes, the default reference for the arduino analogRead function is to use whatever voltage is powering the Avcc pin as the 100% reference voltage for the A/D conversion. So if your chip is powered with +5vdc then +5vdc applied to a analog input pin will result in a 1023 count value, if the chip is powered with 3.3vdc then 1023 will result with 3.3vdc applied to the analog input pin.

Lefty