2017년 9월 10일 일요일

On/Off button with URL links away to the website


Very new to this app making, but i was wondering i followed a few youtube video in creating an on / off button that seemed to work quiet good but i am having issues adding a URL that need to connect once and toggle back to the next state without leading away to that URL 
I dont think this should be that difficult to work out but i am now struggling to find a solution that works.
Something isnt quiet right with my block diagram.
Any ideas please.


--
Probably the best thing to do is incorporate a "first run" variable, you will need a variable and another if/then block.

variable set to FALSE

If button ON then set variable to TRUE then go to url
If button ON and variable = TRUE do nothing

much the same for button OFF

You may need to reset your variable in some way to get back to the default state.

--
I managed to follow this Youtube video seen here Toggle Button In MIT App Inventor 2 | Part 3
☘Hello Guys, In this I have shown How to Make Toggle Buttons In MIT app Inventor 2. This is requirement of many projects For Example you can use Toggle Button to control An LED there is no need to use Two buttons for ON & OFF you can use Only One Toggle Button.☘
which works fine but i am not able to setup the logic as mentioned in your reply.
I have tried a few things with little success I have removed the blocks to one side but i am not sure in what order they go or if this is correct
My diagram is seen here.
I am certain someone here has done this sort of layout before.
Apologies but i am not good at coding.



--
In simplest terms a toggle button can work like this:



Could you explain again exactly what you want to happen with your urls, I may have misunderstood first time around?

--
Thank you for your reply, i really appreciate your help
Sorry for any confusion
I will explain in more detail what i am doing
This is a electronic project that i have and it is a ESP8266  wifi module ( please see image below ) that allows me to toggle a relay to ON and Off state at my home through my router, which i control the opening and closing of my front sliding gate in my driveway.
The program that i have loaded is from an  Arduino sketch  program that allows me to do this and yes it does works as can be expected.
Currently i can control this through my web browsers through my pc at home or anywhere outside my network eg http://myipaddress/gateON   or http://myipaddress/gateOFF

ESP8266 wifi module
Now all i need is the app that goes with it that allows me to toggle this state to ON or OFF without redirecting me away to that URL
So this is what i have been trying to do all along
The Youtube video i have been watching is what i need, but i just need to have the URL toggle once only for each state to have my relay working.
Any ideas how i can set the block diagram to do this.
Please.........?

--
You should be able to do something with the Web component, assuming the urls you send have all the information needed to complete the task
(just using web.get works fine for submitting google forms, so do not see why this won't work)


You may need to do more work with the responses (if any) - would be good to get the feedback that the gate is opening / closing, or that at least the message has been received

--
You might want to add a confirmatory choosedialog notifer in the mix too, just to avoid unnecessary button touches / gate openings/closings

e.g. "Are you sure you want to open the gate?"  Yes/No If Yes > send the url to open the gate, otherwise do nothing. Similarly for closing.

--
I have setup up your block diagram as you just shown..
The circuit turn on but this does not toggle back to off state.
Any ideas.

--
Can we understand the gate process?

From what you say we need to send a "Gate ON" url, followed by a "Gate OFF" url ? then set the button in the app to OFF ?

--
I'm sorry, in my haste I relaise i left some blocks out that change the text of the button. Change to this:


--
Thanks Tim you are a god.
That worked great.
This is egg-zak-lee what i wanted.
With regards to your other suggestion i will take this into consideration and see if i am able to do this on my very own.
But for now i am very happy with what i got.
I can now have this on my android device and this will solve a lot of my issues, making it more convenient switching on and off the relay for my front gate.
I will mark this as solved.

--
Having made a mess of the blocks previously, to make up I provide a couple of examples of an extra step to prevent unintended activation of the relay. :)

Got me thinking though:

How do you know the state of the gate. Can your system tell you if it is open/closed, what state the relay is in?

Also, you might want the gate to close after a set time period? You could automate this after an "ON" by using a clock timer to trigger the OFF event.

Similarly you may want to open the gate at a set time?

-- 

댓글 1개:

  1. According to Stanford Medical, It's indeed the SINGLE reason women in this country live 10 years more and weigh 42 pounds less than we do.

    (And realistically, it is not related to genetics or some secret exercise and really, EVERYTHING to "how" they eat.)

    P.S, I said "HOW", not "what"...

    Click on this link to find out if this brief test can help you find out your true weight loss possibility

    답글삭제