Task: Build your own AtariLab
Needed: Arduino UNO, Arduino IDE software, Jumper wires, Breadboard, Arduino Sensor KitÂ
Time: about 1-2 hours with all components ready
Introduction
I have previously posted about the wonderful AtariLab kits that made it possible to conduct experiments through light and temperature sensors, for example. It is also possible to use an Arduino microcontroller to read a variety of different sensors and send those values to the Atari through the SIO or joystick ports. I have previously posted about connecting your Atari 8-bit computer to an Arduino through the SIO port and the joystick port.
In this project I demonstrate how the joystick port can be used to read a digital signal from the Arduino connected to a motion sensor. The Atari can receive input with high bits (1) when motion is detected and low bits (0) when there is no motion. These digital values are sent through pin 1 of joystick port A and are read using the BASIC command STICK(0). When the Atari powers on the four pins connected to the PIA chip are all initialized with values of 1. These four bits (1111) are equal to decimal value of 15 and are consistent with the joystick in the resting position. The Arduino sends a value of 0 when there is no motion detected. Since this is the first bit, the resulting 4-bit nibble is 0111 which translated into the decimal value of 14. We will see this value if we read joystick A with STICK(0) and print it to the screen in BASIC. When motion sets off the motion detector a value of 1 is sent resulting in 1111 or 15. Thus, we can read the 14 or 15 and indicate on the screen whether motion was detected. This is exactly what the BASIC program I include below does.
There are many types of sensors that can be purchased for the Arduino. These include temperature sensors, sound, light, and motion. I purchased three different kits each with multiple sensors. The first kit is made by ELEGOO and includes 37 sensors for about $30 from Amazon. The second by DIYables includes 30 sensors and sells for about $60 on Amazon. The third is made by Arduino and is nice because the sensors are built into a nice module. This one is available on Amazon for about $37. This one can be mounted on top of the Arduino UNO unit. For this project, I used the HC-SR501 PIR Infrared Sensor by HiLetgo that came in my DIYables kit. Note that this can be purchased individually or in sets of two or three for less than $10 from Amazon.
The HC-SR501 sensor has three connectors for 5V of DC (right), ground (left), and digital output (middle). Note that left-right orientation is from looking at the sensor dome on top. It is quite sensitive and comes with orange potentiometers for adjusting the time delay and the sensitivity. I didn’t play with these but can see how they might be useful.
Instructions
First, connect the HC-SR501 motion sensor to the Arduino. I used a red wire to connect the 5V input (on right if looking down from white dome) on the sensor to the 5V output on the Arduino. I used a black wire to connect the ground (left) to the ground pin on the Arduino. I used a white wire (middle) to connect the digital output pin of the sensor to digital input pin 2 on the Arduino. This will send a 1 if motion is detected and a 0 if no motion. See image below for visual example.
Second, connect the Arduino to the Atari. Here, I used a black jumper wire with female-male ends to connect the Arduino ground (male end) to pin 8 of the Atari joystick port (female end). I did the same with a green wire connecting digital output pin 4 of the Arduino to pin 1 of the joystick port. See image below for visual example.

Third, enter the code for the Arduino in the Arduino IDE. Here is the text file with the code that can be copied and pasted into the IDE. This code simply reads the digital output from the motion sensor on digital pin 2 of the Arduino and then writes the binary values back out through digital pin 4 to be sent to pin 1 of the joystick port. The code also lights up the LED light included on the Arduino board when motion is detected for local confirmation that the sensor is working.
Fourth, power up you Atari and enter the BASIC code from below. Here is the text file.
10 GRAPHICS 2+16 20 POKE 752,1 30 SETCOLOR 2,0,0 40 SETCOLOR 0,12,8 50 POSITION 6,4 60 S=STICK(0) 70 IF S=15 THEN PRINT #6;"MOTION!" 80 IF S=14 THEN GOTO 10 90 GOTO 50
Finally, it is time to try it out. Plug in the Arduino board to your PC using the USB cable and compile the code in the IDE. Now RUN your Atari BASIC program. If everything is working correctly you should see MOTION! print on the screen of the Atari whenever you move your hand or body near the motion sensor. As mentioned above, you can adjust the sensor for speed and sensitivity using the orange potentiometers.
Comments
I am looking forward to exploring more of the sensor options. There is so much one can do with this this. Note that I also tried the temperature sensor in the ELEGOO kit and it worked just fine. Here, I had to use multiple bits to get enough decimal values for a range of temperatures. Ideally, one would use both joystick ports to get an 8-bit byte for 64 values.