// set a2d reference to AVCC (5 volts) cbi(ADMUX, REFS1); sbi(ADMUX, REFS0);
ADC Multiplexer Selection Register - ADMUX ADC Multiplexer Selection Bit 7 6 5 4 3 2 1 0 REFS1 REFS0 ADLAR - MUX3 MUX2 MUX1 MUX0 ADMUX Read/Write R/W R/W R/W R R/W R/W R/W R/W Initial Value 0 0 0 0 0 0 0 0? Bit 7:6 - REFS1:0: Reference Selection Bits These bits select the voltage reference for the ADC, as shown in Table 74. If these bits are changed during a conversion, the change will not go in effect until this conversion is complete (ADIF in ADCSRA is set). The internal voltage reference options may not be used if an external reference voltage is being applied to the AREF pin. Table 74. Voltage Reference Selections for ADC REFS1 REFS0 Voltage Reference Selection 0 0 AREF, Internal Vref turned off 0 1 AVCC with external capacitor at AREF pin 1 0 Reserved 1 1 Internal 2.56V Voltage Reference with external capacitor at AREF pin
cbi(ADMUX, REFS1); //clear REFS1 bit (0) cbi(ADMUX, REFS0); //clear REFS0 bit (0)
vorb: in case you'd rather not mess your wiring.c file, you should be able to put those lines in your setup() function and get the same effect. It might make it easier to share your code or upgrade to future Arduino versions.
#ifndef cbi#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))#endif#ifndef sbi#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))#endif
is it possible to use a aref, that is higher than 5V? for example 7V?
If you want higher use an opamp.
QuoteIf you want higher use an opamp. or a voltage divider (two resistors).-j
Any ratio between 0 and 1 is possible. That is, using resistors alone it is not possible to either reverse the voltage or increase Vout above Vin
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16