Task: Control a Servo Motor with a Joystick from Your Atari 8-Bit Computer Using an Arduino Connected to the SIO Port
Needed: Arduino UNO, Arduino IDE software, SIO cable, Jumper wires, Breadboard, 10k ohm Resistor, Servo
Time: about 1-2 hours with all components ready
Introduction
In a previous post, I explain how to connect an Arduino microcontroller to an Atari 8-bit computer through the SIO port. I build on this project here and demonstrate how to use this setup to control a servo motor. Servos provide fine control over the rotation of a gear that can be attached to objects like a lever arm for use in robotics. This opens the door to numerous applications with control from the Atari.
Instructions
First, purchase a servo motor. I bought an MG90S that has metal gears. I was able to purchase two for about $11 from Amazon. You can save about $5 by buying the SG90 model that has plastic gears. The nice thing about this type of servo is that it has female jumper wire connectors built in for the 5v DC voltage, ground, and a control input.
Second, complete the previous project to connect your Atari to an Arduino through the SIO port. Make sure everything is working.
Third, connect the 5v output of the Arduino to the red (middle) wire of the servo using a red jumper wire. The 5v out port is right next to the two ground ports. Connect the remaining ground port on the Arduino to the brown wire of the servo. Next, connect digital port #9 on the Arduino to the orange input wire of the servo using an orange jumper wire. Refer to the image below.

Fourth, load the code for controlling the Arduino into the Arduino IDE on your PC. Here is the text file with the code that you can copy and paste. Below is a screenshot of the code in the Arduino IDE. Press the load arrow (top left of IDE window ->) that will compile the code and execute it on the Arduino.

Fifth, boot your Atari 8-bit computer into BASIC and enter the following short program to read the left and right movement of the joystick and POKE 54018 with values 52 to send the cassette motor on signal and 60 to turn the cassette motor off. The Arduino program above reads this signal as values of 1000 or higher when the motor signal is on and less that 1000 (or 0) when the cassette motor is off.
100 S = STICK(0)
110 IF S=7 THEN POKE 54018,52
120 IF S=11 THEN POKE 54018,60
130 GOTO 100
Sixth, if everything is connected, loaded, and powered on you can run the BASIC code above and then start moving the joystick left and right. Here is a short video of what you should see:
Video of and Atari joystick controlling a servo motor
Comments
I have wanted to do this project for a really long time. This opens the door to so many possibilities! For example, you could use a servo to control various functions of a model railroad such as track switching. You could also use a servo to control a robot arm.
One thing to keep in mind is that each servo is a little different. I was having trouble getting my servo to move exactly 90 or 180 degrees. This is a known issue that can partly be solved by using the myservo.writeMicrosecond command instead of myservo.write. The pulse that controls a servo is measured in microseconds. For example, some servos will move full left with a 1000ms signal and full right with a 2000ms signal. I couldn’t quite get mine to do what I want. I am sure with some more tinkering I can get this right.