hello! I am trying to speed up a timer whereby a sensor takes Nano D10 low to start and D11 low to stop.
I (think) I have figured out digitalWrite setup( although that probably wont help speed up?) but cannot figure out how to replace digitalRead with direct port addressing......
THANKS
Thanks! I think I've got it.....I needed to put some extra brackets in the first 'while' to get it to compile is that OK??
Now if I run the new program with D11 held low and initiating by taking D10 low to record time I get 5049212.... whereas before it would give 2524606....? so it seems exactly double??
ElapTime is .004... was.008 so twice as fast! interesting. The program byte size has hardly reduced though.... I was expecting more.
I was just looking for confirmation that the sketch that I have written is 'OK', it works, but is it 'correct' , website links don't help to answer my query.
Thanks everyone anyway, I'm sure its very clear to 'Anne Expert'
jetstuff:
I was just looking for confirmation that the sketch that I have written is 'OK', it works, but is it 'correct' , website links don't help to answer my query.
Thanks everyone anyway, I'm sure its very clear to 'Anne Expert'
In fact, the documentation is absolutely the right place to find out whether what you're doing is correct. All you can get in a forum are educated opinions. You should eschew the sarcastic name calling, it makes you appear very immature.
I would think that elap is the number you are looking for.
Thanks Crossroads, yes elap time exactly halved which made me suspicious that I have done something wrong in the program. I was also expecting some size reduction after getting rid of digitalRead, (but that's not a problem).
The 196850 just relates to distance between start/stop sensors.
I'm not an experienced coder, I just cobble together bits that work for me. Its a program that has worked well previously, I was just trying to speed it up for better timing accuracy, I didn't want to re-invent it, just speed it up by getting rid of digitalRead. Do you think there is a better option?