New answers tagged

1

The problem is that LEN is evaluated locally for each usage replacing it with the content. In myFunction the parameter being passed to it is a pointer, not the array. You need to evaluate the size once and once only in the context where the array hasn't collapsed into a pointer. That is usually done immediately where the array is defined: const char* ...


0

First, you should really not use a global variable to get the result of your comparison function. That is only confusion and unnecessary complicated code. For that we have return values. So instead of setting the compareVar variable inside the timeCompare() function, you should just return the corresponding value. In the timeCompare() function replace ...


3

When you want to perform actions in response to button presses, you should take care of reacting to the signal edges rather than levels. In other words, you perform the action only when the signal changes from LOW to HIGH, not every time you see it HIGH. You should also read about button bounce, and either implement your own debouncing or use an existing ...


1

Michael has already given you some excellent advice on how to clean up your code. Your switch statement does not make much sense. You're switching based on an out-of-range index into an array of constants. Once you've read the states of all your buttons as outlined by Michael, your loop needs to decide what to do about the state of each switch. Is this a ...


1

Next time align your code with ctrl-K (after selecting). And yes, you can heavily optimize your code (for maintainability) using arrays: Instead of const int buttonPin1 = 2; const int buttonPin2 = 3; const int buttonPin3 = 4; const int buttonPin4 = 5; const int buttonPin5 = 6; use const int buttonPins[] = { 2, 3, 4, 5, 6 }; In software engineering it's ...


0

I don't have a compiler at hand, but you can cast the array as a char and uint8_t are similar in size: rf95.send((char*) udp_to_lora, sizeof(udp_to_lora));


Top 50 recent answers are included