CE 432 Fall 2021
HW 5: Joystick/Stepper Motor Tutorial
Taylor Nakai
tsnakai@fortlewis.edu

Introduction:
In this homework, we followed Dr. Li's Joystick/Stepper Motor Tutorial that was provided. The tutorial had us go through tutorials to help us learn more about the joystick, the Open-Smart 2.4 GHz transceiver, and the NEMA17 stepper motor. This homework was necessary as it alllowed us to gain experience and comfortability with these three parts to prepare us for upcoming Robotics II Projects like the Two-Wheel Balancing Car. The first task required us learn about the joystick and how it is actually a bi-directional potentiometer. We learned that the joystick provides three readings: the switch, the x-axis, and the y-axis. The second task required us to use two Open-Smart transceivers, one would be connected to the joystick and transmit the data, while the other would act as a receiver. The third task required us to use the transmitted data to control the NEMA17 stepper motor. The tasks built on top of each other, so making sure you understood what was going on was critical.

Materials:
MaterialsQuantity
Analog Joystick1
Open-Smart Transceiver
2
Arduino Uno2
A4988 Motor Driver1
NEMA17 Stepper Motor1
100 uF Capacitor1
Lipo Battery3
Bread Board1
Lipo Battery Catridge1
Jumper CablesInfinity

Task 1: Joystick Test
In Task 1, it required us learn about the joystick and how it is actually a bi-directional potentiometer. The first step had us follow the wiring diagram provided to connect the joystick to the Arduino Uno. Once the joystick was successfully connected to the Arduino, seen in Figure 1, we were able to upload the example code and open the serial monitor to see the readings. We learned that the joystick provides three readings: the switch, the x-axis, and the y-axis. The orientation of the joystick that I used to test my values were similar to what is shown in Figure 1. When the joystick is pushed, the switch reading will change from '1' to '0'. When the joystick is moved into the upwards position, the y-axis reading changes to '0' while the x-axis reading remains '508'. When the joystick is moved into the downwards position, the y-axis reading changes to '1023' while the y-axis reading remains '508'. When the joystick is moved into the left position, the x-axis reading changes to '0' while the y-axis reading remains '485'. When the joystick is moved into the right position, the x-axis reading changes to '1023' while the y-axis reading remains '485'. When the joystick is in the resting position the x-axis reading is '508' and the y-axis reading is '485', which is supposed to be close to '512' for both as that is the middle of 1024. The results of the different joystick positions can be seen in Figure 2.


Figure 1. Setup showing the connections needed to connect the joystick to the Arduino Uno.


Figure 2. Joystick readings and the associated position that caused the reading.

Task 2: The Open-Smart 2.4 GHz Transceiver
In Task 2, it required us to use two Open-Smart transceivers, one would be connected to the joystick and transmit the data, while the other would act as a receiver. Both the transmitter and receiver were both connected to an Arduino Uno. The first step had us follow the wiring diagram provided to connect the receiver circuit and the transmitter circuit. The completed circuits for the receiver and transmitter are seen in Figure 3. The example code for the receiver and transmitter were then uploaded to each respective Arduino. It was notice that the reading from the joystick was sent one number at a time and had a newline for each number. This is because the data is sent and received one byte at a time, in terms of characters, as seen in Figure 4. In order to fix this so that the numbers are read together as one number, we needed to concatenate the characters into a string looking for the newline delimiter that indicates the reading is done being transmitted. Once we had the reading as a string, we were able to use the '.toInt()' function to cast the string to a integer that could be understood as a numerical value, as seen in Figure 5.


Figure 3. Setup of the receiver and transmitter circuits.


Figure 4. Code and associated reading showing the reading being transmitted one byte at a time.


Figure 5. Code and associated output showing the reading as one numerical number.

Task 3: Use the Received command to control the NEMA17 Stepper Motor
In Task 3, it required us to use the transmitted data to control the NEMA17 stepper motor. The first task was connecting the A4988 motor driver, the stepper motor, and the 3 lippo batteries to the existing circuit that we had used in Task 2, as shown in Figure 6. Once that was completed, we were able to upload the provided code that built on top of Task 2 to both the receiver and transmitter. The analog joystick's reading was converted to a digital reading (0-1023) by the Arduino Uno, sent through the transmitter to the receiver, that is then sent to the other Arduino Uno where it is packaged, sent to the motor driver where it rotates the stepper motor depending on the movement of the joystick. Once successfully completed, we were able to demonstrate that we were able to control the stepper motor using the analog joystick as seen in Figure 7.


Figure 6. Setup of the circuit that will be able to control stepper motor using analog joystick.


Figure 7. Demonstration of analog joystick controlling stepper motor.


Discussion:
By completing this tutorial, we were able to gain comfortability using the analog joystick, the Open-Smart transceiver, and the stepper motor. I spent a couple hours trying to figure out why my Task 2 was not working, turns out that one of my transceivers was no good. Learning how to use joystick, transceivers, and stepper motor was interesting. It was interesting to learn how the transceivers communicated, and I think that will come in handy when we build the two wheel balancing robot. Besides the transceiver not working, this was a good tutorial where I was able to learn a lot. Overall, this tutorial was fun and I hope that we get to use the joystick or transceiver more in the future.
------------------------------------------------