Control Motor using radio and Pico W #1938
Replies: 2 comments 2 replies
-
Have a look at your main sending code. It is always broadcasting 0 even if you hold one of the buttons. So your are broadcasting You might want to change the sending logic to only change the broadcast signal when the button state changes, rather than re-broadcasting the same values over and over. For example, you could:
|
Beta Was this translation helpful? Give feedback.
-
I fixed the code like below
As you can see, I add machine.Pin.PULL_DOWN when register the Pin, this make the result a lot more stable, no more floating value. Next, I use old_data variable, this will help the program only broadcast when the button changed states (Forward, Backward, Stop). With these fixes, my program run perfectly as I needed. If you have any idea to improve, just tell me. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I tried to control a motor ( attached to Port C of a Technic Hub) via 27Mhz radio control.
The radio receiver board is connected to my Pico, and the Pico will read the signal from it and broadcast to the Hub by BLE to control motor. The pico is placed next to the Hub.
The pi broadcast the signal with no problem but the hub is very unstable when receiving.
Here is my code on the pi
and here is the code from the hub
When I press and hold the button, here is the received data:
It's very unstable.
Can anyone have any solution ?
Beta Was this translation helpful? Give feedback.
All reactions