General area when it fits no where else

Moderator: Mmiscool

User avatar
By Electroguard
#45916 Yes captain, I've already tried all the other pins, and alhough the others don't cause a crash and burn, none branch to invoke the print "response" even though leds show me that the pin itself is operating.
Previously I set up a toggle routine in the branch to toggle a led, but it never did, so I stripped things down to just the simple 'print' statement... but nothing has ever shown on the browser screen.

I've tried using different branch names and print msgs and crossing my fingers etc, but still never had any sign that a button press has ever reaches the branch.

If I could have got it working without bothering you I would have, but after many hours of trying everything I could think of, I have to conclude that the interupt function appears not to work (I hope I'm wrong), which is something I thought you'd want to know about and check out for yourself.


Footnote - The one thing I'm not sure about is the pin designations.
I've been using just the number 0 for gpio00 and 16 for gpio16 etc, but I've seen previous articles that stipulate eg: D3 ... I'm sure I found out ages ago that eg: D3 doesn't correspond to gpio03, but there's still that element of uncertainty about what/why the use of the 'D' prefix.
User avatar
By Mmiscool
#45934 It is not a bidirectional link between the browser and the device. The browser requests information. The esp acts on it and returns a response. If you were to refresh the page you would see the printed output. If you look at the serial terminal the output is instant. Press the vutton and it will instant send to the serial.

You could add a bit of auto refrest html to your program to refresh the page at intervals to see if any new text has been printed.
User avatar
By Electroguard
#45939 So I think what you are saying is that the code below doesn't locally toggle the esp's led with each button press because the browser screen doesn't get a refresh each time? It's still WAITing?

To put things into context - I've already pounced on Alpha 15 which has let me get my udp framework functioning... so now I can start doing some practical network node projects with it.
The first was to be a PIR sensor node for sending PIR trigger alerts to other nodes, but I couldn't get ESP_Basic to respond to the incoming triggers on the gpio inputs, so I eventually got funnelled into just trying to react to a button press, but can't even manage that yet.

It would have been nice to have it interupt driven, but its not too essential so long as it can be responded to within 1 second.

So is there some way for ESP_Basic to monitor a PIR output (or button) on a gpio input pin and take some form of quick local response irrespective of browser refresh?

Code: Select alllet inputpin = 0             'gpio button
let ledpin = 1                 'gpio led
let ledstate = 1
interrupt inputpin [pressed]
wait

[pressed]
if ledstate == 1 then ledstate = 0 else ledstate = 1
po ledpin ledstate
wait
User avatar
By Mmiscool
#45944 The program you posted should toggle the led.

The interupt code is exicuted imidiatly. If there is an action like toggling another gpio or putting some thing on an oled display it will work perfectly. You vould evin send a udp msg on button pres. If you print some thing it will not show up in the browser untill the page is refreshed.