Go Down

Topic: Hall Sensor on analog pin (Read 459 times) previous topic - next topic

cimon

Hello

I am using the http://www.seeedstudio.com/depot/datasheet/water%20flow%20sensor%20datasheet.pdf  this sensor with ATtiny85.
The datasheet specifies the output as a digital pulse.

I use it as an interrupt and the sensor works perfectly when connected and tested with the digital pin on Arduino.
Because I am already using both the digital pins of ATtiny, I am connecting the sensor to the analogue pin of ATtiny but I am not getting the expected result.

I tried to use the digital pin to debug my code. But I want to make if the sensor is intended to work with digital pin only? or it can also work with the Analogue pin ?

Thanks

Grumpy_Mike

Quote
I use it as an interrupt and the sensor works perfectly when connected and tested with the digital pin on Arduino.

You can't use the analogue pin to generate an interrupt.
Can you redeploy one of your other digital signals to the analogue pins and use a real digital pin?

johnwasser

Any signal that works with a digital input pin (0V, 5V) will work with an analog input. The analogRead() function will return a value near 0 for logic LOW signals and a value near 1023 for logic HIGH signals.  Compare the returned value with 512 (mid range) to get a logic value.

Most (but not all) analog input pins can also be used for digital inputs and outputs. I don't know if the core you are using supports this or not.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Go Up