Go Down

Topic: Does AnalogRead() use any timer ? (Read 2358 times) previous topic - next topic

Nick Gammon

Quote
i tried as you suggested


Oh? Post the code where you tried.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Hello,

Below is the code i tried

Code: [Select]



int fsrPin = 0; // the FSR and 10K pulldown are connected to a0
int fsrReading; // the analog reading from the FSR resistor divider

void pinChange()
{

fsrReading = analogRead(fsrPin);
   
}

    void setup(void) {
       
       Serial.begin(9600); // We'll send debugging information via the Serial monitor
attachInterrupt (0, pinChange, CHANGE);  // attach interrupt handler
    }

    void loop(void) {

    Serial.print("Analog reading = ");
    Serial.println(fsrReading);
 
  }




In the above code, i don get any values from ISR.
Thanks
Anand

PaulS

Quote
Below is the code i tried

Apparently, you didn't do as Nick suggested. That code looks nothing like the example on his site.

Nick Gammon


Hello,

Below is the code i tried
...
In the above code, i don get any values from ISR.
Thanks


Thanks for what? You have totally ignored my suggested code.

I didn't say "attach an interrupt and everything will be solved". I posted code for starting an ADC conversion without waiting, using an interrupt to detect when that finished, and getting the converted value.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up