Motor Rotation Based on Joystick Counting
This Python code demonstrates a joystick-controlled motor rotation system that enables a user to count joystick inputs and control the motor's rotations accordingly. The application uses a USB-connected motor controller to read joystick inputs and perform precise motor movements based on the input count. Below is a step-by-step explanation of the code.
About Tools and Materials:
SMD USB Gateway (Purchase Here)
Joystick Module (Purchase Here)
Step 1: Hardware & Software Overview
Key Components:
ACROME SMD The ACROME SMD acts as the communication hub between the Joystick Module and the computer. It collects Joystick Module data, processes user input, and translates it into mouse movements and clicks.
Joystick Module The Joystick Module serves as the main input device. The user can move the Joystick Module to control the mouse pointer’s X and Y coordinates on the screen. Additionally, the Joystick Module button can be used to trigger mouse clicks.
BDC Motor The motor is controlled using velocity commands, allowing for smooth acceleration and deceleration.
Project Features:
Button Press Detection: Reads the joystick button state from the motor controller.
Entering Counting Mode: Holding the button for 5 seconds activates counting mode.
Incrementing the Counter: In counting mode, pressing and releasing the button increases the counter.
Triggering Motor Rotation: Holding the button for another 5 seconds rotates the motor according to the counter value.
Step 2: Assemble
Getting Started
Hardware Setup
Connect the SMD to the PC or Arduino board using USB Gateway Module .
Connect the BDC Motor and the Joystick Module to the SMD using an RJ-45 cable.
Make sure that the SMD is powered and all connections are correct
Project Wiring Diagram
Step 3: Run & Test
Run the Script
• Execute the script to initiate the Motor Rotation Based on Joystick Counting project.
• The script will automatically detect the USB port and establish communication with the SMD Master Controller.
• Move the joystick to control the motor’s rotation and observe the response.
Experience Joystick-Based Motor Control
• Move the joystick forward to rotate the motor clockwise (CW).
• Move the joystick backward to rotate the motor counterclockwise (CCW).
• Return the joystick to the center position to stop the motor.
• Observe how the motor speed and direction change dynamically based on joystick movement.
Codes
Last updated