Arduino Mega 2560 with some C - not reading analogue pins
hello everyone,
i facing problem code possibly as, want overclock adcs (for audio recording)
and store samples sram or external module. can not understand keep getting
the value "1023" whether there input or not , can not pretty udnerstand this! should declare want
the analog pins work input? , why not work? if have questions please let me know.
thank in advance,
napster
i facing problem code possibly as, want overclock adcs (for audio recording)
and store samples sram or external module. can not understand keep getting
the value "1023" whether there input or not , can not pretty udnerstand this! should declare want
the analog pins work input? , why not work? if have questions please let me know.
thank in advance,
napster
code: [select]
int time;
#define fastadc 1
// defines setting , clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_sfr_byte(sfr) &= ~_bv(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_sfr_byte(sfr) |= _bv(bit))
#endif
void setup() {
int start ;
int ;
serial.begin(9600);
#if fastadc
// set prescale 2,16,32 etc
cbi(adcsra,adps2) ;
cbi(adcsra,adps1) ;
cbi(adcsra,adps0) ;
#endif
}
void loop() {
time = micros();
int sensorvalue = analogread(a0);
time = micros() - time;
serial.print("\n");
serial.println(time);
serial.print(sensorvalue);
delay(100);
}
i moron, fogot set pinmode, can done in c , wiring
Arduino Forum > Using Arduino > Programming Questions > Arduino Mega 2560 with some C - not reading analogue pins
arduino
Comments
Post a Comment