• ok, thanks for comment, I will expand.

    All of the code loaded on the smartibot is in the attachment.

    The smartibot comes with an android or Iphone App which has some pre-defined panels.

    As a default, when the smartibot is connected to the App it is possible to control the motors using a D-pad .
    It is possible to create your own panel, I have added two buttons, I can see the confusion because I referenced them as Button 1 and 2.

    Lets call them Auto and Manual.

    On the App it is possible to execute a command when a button is pressed and released.

    So the code attached on the original post has been downloaded to flash but it does not automatically run when the smartibot is powered up.

    I am trying to use the smartibot as follows:

    switch on the smartibot and connect to the app.
    Control it using the D-PAD
    Press the auto button which sends text to the smartibot "load()", which then loads the program from flash into RAM.
    Release the auto button and it sends "wallAvoid()" to the smartibot, which now executes the function "wallAvoid()". The smartibot then moves automatically according to the measured distance.

    Press the manual button on the app and it sends text "stopWallAvoid()", the smartibot now stops moving.
    Release the manual button on the app and it sends text "reset()".
    At this point I wanted to take control from the D-PAD again, this does not happen.
    But I can toggle between auto and manual mode.

    So based on the definition of reset, extract below.
    "If reset() is called with no arguments, it will reset the board's state in RAM but will not reset the state in flash. When next powered on (or when load() is called) the board will load the previously saved code.
    Calling reset(true) will cause all saved code in flash memory to be cleared as well."

    I expected the D-PAD to work.

    Am I correct in that assumption?

    I hope this explains what I was trying to do, there is no need to look at the reddit group, that is where it was suggested to call load() and wallAvoid from a button press. Based on that suggestion which worked I added the code for stopWallAvoid and reset.

    As I am about to hit post I have realised a work around, add my own functions for forwards, backwards , left , right and call them when the D-pad on the phone is used.

    Thanks for the response, I will add more detail next time and post links,

About

Avatar for user104966 @user104966 started