Pages: 1 [2]   Go Down
Author Topic: attiny 45/85,attachinterupt problem. Need help  (Read 1656 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 250
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 613
Posts: 49318
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 250
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: November 27, 2010, 04:23:49 pm by acmilangr » Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 613
Posts: 49318
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 250
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
 :'( :'(
« Last Edit: November 27, 2010, 04:37:02 pm by acmilangr » Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 613
Posts: 49318
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 250
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: 1 [2]   Go Up
Jump to: