can someone tell me why is don't work when I add long unsigned to" long unsigned currentmillis = millis(); "
at start of main loop . it works perfect if I take "long unsigned "out but it needs it for roll over.
it is a debouncer I made.
unsigned long currentmillis=0;
unsigned long buttonmillis=0;
unsigned long previousmillis=0; #define led 8 #define D4 4
int button=0;
int buttonTime=200;
There is a global variable currentmillis declared as an unsigned long. When you use the global variable, both loop() and Button() can use the global variable, and they use the same one.
When you declare unsigned long currentmillis inside your loop() function, it allocates another local variable named currentmillis, and sets it to millis(). This is not the same variable as the global currentmillis. Your Button() function cannot access the local variable in the loop() function. It uses the global currentmillis variable instead. But that variable has not been set.
thanks that's what I figured , iv only been coding a few days so im not good with this stuff. I fixed by just using the millis() instead of the currentmillis in the time comparator inside the button loop. Thanks for your input. This stuff gets tough.