According to the DataSheet we end up with 6 channels:
Also note that MUX5 should be cleared in order to use ADC0:7
000 ADC0
001 ADC1
010 N/a
011 N/a
100 ADC4
101 ADC5
110 ADC6
111 ADC7
In order to read the other 6 channels ADC8:13 we must set MUX5 and the assigments for MUX2..0 are:
000 ADC8
001 ADC9
010 ADC10
0011 ADC11
100 ADC12
101 ADC13
110 N/a
111 Temperature sensor N/a
It´s very important to note that MUX5 is not part of ADMUX as in other 8 bit AVRs but is part of ADCSRB.
Lets start with the code: This function will initialize the ADC
The following function will get the ADC channel we want to read as parameter:
Finally for readability(vinciduino form factor) and portability I added the following defines
Then if we want to read any value we may use:
0 comentarios:
Publicar un comentario