Yes, the software doesn't yet support the extra analog inputs. But take a look at ARDUINO/lib/targets/arduino/wiring.c and pins_arduino.c, you might be able to add the support easily.
Yes, the software doesn't yet support the extra analog inputs. But take a look at ARDUINO/lib/targets/arduino/wiring.c and pins_arduino.c, you might be able to add the support easily.
i must admit, i already had one look to see if could find something. didn't think it would be too easy. but i promise to try with a little more time in the next days.
kuk[ch65306]
I think mellis is right , AD6 and AD7 are the number of "CH" , it is easy to add them ,and make them work . but I don't have "Arduino Mini" , so I can't test it , I will buy some M168 next week to make it sure.
the code:
int analogRead(int pin)
{
unsigned int low, high, ch = pin;
// the low 4 bits of ADMUX select the ADC channel
ADMUX = (ADMUX & (unsigned int) 0xf0) | (ch & (unsigned int) 0x0f);
// without a delay, we seem to read from the wrong channel
delay(1);
// start the conversion
sbi(ADCSRA, ADSC);
// ADSC is cleared when the conversion finishes
while (bit_is_set(ADCSRA, ADSC));
// we have to read ADCL first; doing so locks both ADCL
// and ADCH until ADCH is read. reading ADCL second would
// cause the results of each conversion to be discarded,
// as ADCL and ADCH would be locked when it completed.
low = ADCL;
high = ADCH;
// combine the two bytes
return (high << 8) | low;
}
i'm doing a little trial & error with no success so far.
do i understand it right that those files "wiring.c" and "pins_arduino.c" from the lib/targets/arduino folder are the EXACT files that are used when my program gets compiled?
do i have to restart the arduino IDE or are these files read each time when i start the compiling process?
so far, i tried my luck mostly in pins_arduino.c, as wiring.c seems to be written quite dynamical. but my programm seems unaffected. i can't even disable one of the existing analog ins :-/
@fallen
did you change someting in the code that you posted?
I'm pretty sure that wiring.c and pins_arduino.c get recompiled every time you compile/verify or upload your sketch, but I can't swear to it. What did you try to disable an existing analog input?
kuk:
Yes , I change "ch = analogInPinToBit(pin) " to "ch = pin" , in "analogInPinToBit(pin)" , there are only return 0~5 , now you can use 0~7, but I don't have "Arduino Mini" , so I can't test it , if it can't work , I so sorry about it.
i think this array maps the numbered pins to the right inputs on the atmega. i tried adding 2 lines
{ PC, 6 },
{ PC, 7 },
but that didn't work. (shouldn't it be ADC instead of PC anyway?) but even after i deleted some of the existing pairs, my program still worked with the six existing analog ins. i don't have my board here at the moment so i cannot work on it right now.