Use this code base to operate a step motor on a Pico Pi W. The idea is to simulate an industrial IOT gate type device.
This code (and diagram.json) is intended to be used with wokwi
-
Go to the wokwi.com page and click Pi-Pico > Micropython to start a new project using a template.
-
Copy the contents of the diagram.json from this repo to the project.
-
Examine the diagram and observe the connections between pins and devices.
-
Use the code from step.py to move the motor in one direction.
- Create a function to simulate making the motor close and open the gate. Your function should make the motor:
- Move the motor position to -90 degrees.
- Wait 60 seconds, then move back to a position of 0 degrees.
- Optionally, you could simulate warning lights by adding an LED that will blink while the gate is moving.
- Optionally, you could simulate a safety mechanism by adding a distance sensor to stop the gate moving if an object is below the gate.
-
Add a button to the system:
- Click + and add a pushbutton.
- Connect the push button (btn 1:1:l to3V and btn 1:2:r to Pico GP:26)
-
Modify the code to call your function when the button is pressed (you may find some ideas in hint.py).
-
Configure the device to join a WiFi network (any should work in the simulator).
-
Configure the device to send UDP messages to any IP when the gate is opened and closed.