Hello everyone Can you please help with the code.
I wanted to add switching between functions to my project. I assume to use the "Switch" function for implementation. But I could not add to the code and make an algorithm.
I want to make such an algorithm:
The project has a touch button and a regular one.
When the button is pressed, the function should change.
Then if you press the touch button, then the algorithm should do the function inside the cell that it stopped.
Again, the digitalRead() function returns either 0 or 1, but not 2. Your second branch will never be reached.
I think you don't need switch statement at all. Your problem can resolved with combination of if statement and incrementing counter.
I think we should not encourage @muhammedjan to get into "bad habits".
According to the Arduino documentation for digitalRead();
Returns
HIGH or LOW
It doesn't say 0 or 1. We know from experience that 0 and 1 are equivalent, and that has never changed and probably never will change. But assumptions like that are the start of a slippery slope!
It would be "ok" to put
switch (digitalRead(18)) {
case LOW:
case HIGH:
but you might was well use if() instead of switch().
(Sorry about this, I seem to have woken up with my purist's hat on today!)