Asked — Edited

Mobile App Continuous Toggle Button

I am working on a mobile app and have a button that I want to be able to toggle. First push would turn leds on and next push would turn leds off. This action should be repeated each time I push the button. The following script toggles button on then off but does not repeat these actions again. Here is the code:



#In Connect Script

$Pressed = 0

#Script for Mobile App Button

if (!$Pressed)
#High Beams On
Set (D17,ON)
Set (D19,ON)
Sleep (100)
$Pressed = 1
Else
#High Beams Off
Set (D17,OFF)
Set (D19,OFF)
Sleep (150)
$Pressed = 0
endif


The first time I push the button the lights come on and the second time I push the button the lights go off. This is good but any further pushes result in no action. I tried putting in a loop but still didn't work. Any thoughts would be appreciated. Rick :)


ARC Pro

Upgrade to ARC Pro

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

#9  

@PTP

I tried again and included $Pressed, $Pressed1 and $Pressed2 in my connection script and the three mobile app buttons are working. Not sure why it didn't work yesterday. I was wondering if it has something to do with the variables being initialized in the connection script rather than a startup script. What is the difference between connection startup script and a separate startup script. Seems that the connection startup script is the best way to go as the script is run automatically on connection. Your thoughts are appreciated....Rick

#10  

@PTP

How do I give you credit for answereing this thread? Thanks again....Rick

#11  

You can't... the thread is not a "require technical assistance" type thread. It is a plain conversation thread ...

#12  

@Richard

Thanks much for the clarification....Rick