What I’m trying to do:
i have a html form that includes a variable that is being changed based on activity on the website. the value is either 0 or 1 and i want to send it through uplink to my raspberry pi pico w. when the value is 1, a motor is activated by the gpio pin, when its 0, it is deactivated.
What I’ve tried and what’s not working:
i have seen that modules can store global variables that can be used everywhere else, but i dont know how to pass the value from the html form to the module.
since i posted my question, i have changed the code a little. The website is supposed to check if the phone is being shaken. if it is shaken, the page turns green, if it isnt, it turns red. while it is shaken, the website should also send the value 1 to my raspberry pi pico w and while it isnt shaken, it should set the value to 0. The script for changing the color depending on the shake status works fine and the connection between pico and the website is also established since i had a test button on it to turn the LED on the pico on and off. In the “if” statement where i set the colors, i added a call function as you can see, because i thought since the color change works, calling to python should work aswell.
The color changes fine, but changing the status of shaking doesnt work. I hope there is a simple solution to that
If you’re using one of the builtin themes then. .content is probably what you want. It’s any dom selector nested within your html form that you’re trying to access.
If you look inside standard-page.html you’ll find a div with that class.
“world” is just an argument being passed to the function. You can pass arbitrarily many arguments. If you don’t need to pass any arguments then leave this blank. But it looks like you need to pass either 1 or 0.
You may want to re-read the docs and which covers this
i changed the two lines of code that call the python function but it still doesnt work. i added another test button which calls the same function with the value 1 and that works, so it must be something between the javascript and the python back end. maybe my problem is somewhere in the setup of the files. i am totally new to programming and anvil, i just want this one thing to work for my little project. i read through the docs again but i cant find the information that would help me.
heres a clone of my app, i would be very thankful if you could take a quick look. i am already thankful for your help so far, i hope we can get this working soon.