Hi I am quite new to the arduino, and i have run into a problem:)
I'm looking to use the Millis inside of different classes for timed events, the millis works fine in the .ino file but when i open/or enter the .h file the class the serial stops...
I have surfed the internet but i couldn't find anything about my problem
is there a way to keep the serial running whne you enter a class?
Or are you using millis() in a delay()-equivalent way like while(millis()-lastMillis < interval){....}? Because that would be silly and block other things.
Let us create a Class based Sketch where the LED1 and LED2 of Fig-1 will blink independently at 2-sec and 4-sec intervals respectively with equal On/Off periods. The millis() function, residing within a Class will controll the intervals. The Serial Monitor spills the messages that the LED1/LED2 have changed states. Pressing SW1 will stop the blinking of the LEDs and the activities of Serial Monitor.
Sketch: 1. Create a Class based simple Sketch to blink only LED1 at 2-sec inerval. The millis() function, residing within a Class controls the interval period.
.... pending
Figure-1:
Hi Everyone thanks for all the replies
I sat down and created a new simpler sketch for a test
Which is shown under
(because the one i am working on is quite big with some led control and so on)
I messed around a little and figured out that it was the while loop, that "stopped, or disabled" the serial communication (or whatever it did) Swapped it out with a if-statement, and all worked fine:)
can anyone tell me why this is?
anyways thanks for all the answers, and sorry for the inconvinence