Fix #70
Untested, but in https://github.com/raspberrypi/pico-micropython-examples/issues/70#issuecomment-2724378336 @dpgeorge says that this should work :wink:
I tested this on a Pico W and it works well.
Might I also suggest the following changes, to make it more user friendly:
- change the led init line to
led = Pin("LED"), so it actually turns the built-in LED on and off - add these two lines to the HTML that it sends (after the
<p>%s</p>):
<button onclick="window.location='/light/off'">Turn off</button>
<button onclick="window.location='/light/on'">Turn on</button>
That gives you buttons to turn on/off via navigation to the correct page.
I tested this on a Pico W and it works well.
Thank you! :+1:
Might I also suggest the following changes, to make it more user friendly:
- change the led init line to
led = Pin("LED"), so it actually turns the built-in LED on and off
See #66 and #71
- add these two lines to the HTML that it sends (after the
<p>%s</p>):<button onclick="window.location='/light/off'">Turn off</button> <button onclick="window.location='/light/on'">Turn on</button>That gives you buttons to turn on/off via navigation to the correct page.
Surely it's easier to just use a href links, rather than relying on buttons with javascript onclick handlers?
EDIT: Which I've just done :wink:
Might I also suggest the following changes, to make it more user friendly:
- change the led init line to
led = Pin("LED"), so it actually turns the built-in LED on and offSee #66 and #71
Ah, right, thanks for reminding me!
Surely it's easier to just use
a hreflinks, rather than relying on buttons with javascriptonclickhandlers?
Yes, simpler to use a href. It's just that buttons look better :smile: although you could use CSS for the hrefs.
although you could use CSS for the hrefs.
Our examples are deliberately kept simple and bare-bones. They're intended to demonstrate the functionality of the underlying code, not HTML styling :wink: