Go Down

Topic: attiny 45/85,attachinterupt problem. Need help (Read 3131 times) previous topic - next topic


but i want to know if there is change on that pin, not to read if this is high or low


On each pass, you need to read the current state of the pin (currValue), and record that. At the end of the loop, save that value as prevValue. Then, a state change has occurred if currValue != prevValue.


Nov 27, 2010, 10:19 pm Last Edit: Nov 27, 2010, 10:23 pm by acmilangr Reason: 1
i think it is not correct

becouse what if in the begining of the loop the state is 1,in the middle is 0 and goes back to 1 in the end of the loop,where the sketh will store it to compare it?

i want the sketch to know if there is change betwwen the void loop


If loop executes fast enough, the chance of a state change occurring in loop is pretty small. But, if the change must be detected immediately, then you must use interrupts, and loop must be written in a way that makes it interrupt-able.


Nov 27, 2010, 10:32 pm Last Edit: Nov 27, 2010, 10:37 pm by acmilangr Reason: 1
is it posible to enable and disable the interrupt when i want to do it? or how else can i fix my problem?how can i make it interrupt-able?
:'( :'(


Dry your eyes and quit crying about it.

Is there more to loop than you first posted? If not, there is no reason that polling would not be adequate. Setting some pins HIGH or LOW, or changing pin mode, or performing digital reads does not take much time.


ok i'll try it tomorrow but as i told you i am sure it will not catch 100% the change becouse maybe it will have the same logic value at that time

Go Up

Please enter a valid email to subscribe

Confirm your email address

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
Torino, 10131