Go Down

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

acmiilangr

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

PaulS

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.

acmiilangr

#17
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

PaulS

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.

acmiilangr

#19
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?
:'( :'(

PaulS

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.

acmiilangr

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