Are there any Arduino people out there. A program that used to work 4 years ago 
now  has an extra feature that gives me grief. This is for  Wemos D1 
microcontroller.

The main loop is fine and  only acts when the loop for the function  
ButtonReading returns a value.

....
 client.loop();
  String payload = ButtonReading();
    ver_disp();
    lcd.setCursor(8,2);
    lcd.print(payload);
....

But The buttonReading routine now needs an else statement at the end which 
returns a value I don't want to process.

String ButtonReading()
{
String payload = "NULL";
Button_State = NOT_PRESSED ;               // reset button_state
do
  {
    if(digitalRead(ButtonUp) == PRESSED)
    {
      String payload = "move/forward";
      Button_State = PRESSED;
      return payload;
    }

.... And a few more button press options
....
    if(digitalRead(ButtonStop) == PRESSED)
    {
      String payload = "stop";
      Button_State = PRESSED;
      return payload;
    }
    else                // this else never used to be needed.
    {
      String payload = "No Action";
//      Button_State = PRESSED;
      delay (2000);
      return payload;
    }

  delay (100);
  }
while (Button_State != PRESSED);

Ideally it should keep looping in the do..while loop but I have tried all sorts 
of things with this else bit to get it to compile and work.
Taking out the 'else' bit gives this error:
error: control reaches end of non-void function [-Werror=return-type]
  199 | }
      | ^
cc1plus: some warnings being treated as errors.

Does anybody know how I can get over this?

Thanks,
Peter M.






--
 Next meeting: Online, Jitsi, Tuesday, 2025-08-05 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  https://dorset.lug.org.uk
 New thread, don't hijack:  mailto:[email protected]

Reply via email to