I have a code which counting the hits of a sensor and I need the program to reset the code once it count 100 hits :o your help will be appreciated , I have already tried digitalRead method but there is something wrong.
THE CODE //
#include <Wire.h> #include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
int ledPin = 13;
int pirPin = 10;
int pirState = LOW;
int val = 0;
int counter = 0;
int currentState = 0;
int previousState = 0;
If you mean you want to reset the counter variable once it gets to 100 why not just put something in that says if the counter is 100 then set counter to 0?
If "reset the code" means something else a bit more explanation is needed.
slipstick:
If you mean you want to reset the counter variable once it gets to 100 why not just put something in that says if the counter is 100 then set counter to 0?
If "reset the code" means something else a bit more explanation is needed.
Steve
Hi Steve
sorry for the confusion that I mad, yes what I meant is to rest the counter once it's reached the desired count.
You need to overwrite the 9 that's there from 99, the 0 only covers the first 9 so it shows 09...
Probably easiest to print a leading space if counter is under 10, then the 1, 2, 3 etc from counter, so it actually puts the new 1, 2, 3 etc in the second position so the units always line up.