Testing Motor Connections
Activity Overview
Students will work with a MicroPython-controlled robot to understand motor control, PWM signals, and basic robotics programming.
Learning Objectives
Students will be able to:
- Understand how PWM controls motor speed and direction
- Identify the purpose of each pin configuration
- Observe and document motor behavior
- Modify code parameters to change robot behavior
Materials Needed
-
MicroPython-compatible microcontroller (Raspberry Pi Pico recommended)
-
Robot chassis with two motors
- Jumper wires
- Computer with MicroPython IDE
Student Activities
Activity 1: Code Analysis
-
Read through the provided code and identify the four motor control pins
-
Explain what the
POWER_LEVEL
constant controls - Predict what the robot will do when the code runs
Activity 2: Initial Testing
- Connect the motors according to the pin assignments
- Run the code and observe which wheels move in which directions
- Record observations for each motor test phase
- Note any motors that don't work as expected
Activity 3: Pin Calibration
- If wheels move in unexpected directions, modify the pin assignments
- Test different pin combinations until all motors work correctly
- Document the correct pin configuration for your robot
Activity 4: Parameter Modification
- Change the
POWER_LEVEL
value and observe speed differences - Modify the sleep times to make movements faster or slower
- Test values between 0-65535 for power level
Activity 5: Movement Programming
- Create new functions for specific movements (forward, backward, turn left, turn right)
- Replace the test loop with a sequence of actual robot movements
- Program the robot to move in a square pattern
Assessment Questions
- What happens if you set
POWER_LEVEL
to 0? - Why does the code use separate pins for forward and reverse?
- How would you modify the code to make the robot turn in place?
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|