Programming Retro

Bluetooth wireless Adapter for Atari Retro Joysticks and Paddles

In a previous blog article, I showed how you can make 2 and 4 port USB adapters to use with retro Atari Joysitcks. While that was really awesome, I recently made improvements leading to this next generation adapter that I will cover in this article. The top improvements are:

  1. Wireless Bluetooth support
  2. Paddle support in addition to joysticks
  3. Additional buttons you can use without having to open up your joysticks

Here is a video that shows the result if you dont feel like reading.

Wireless Bluetooth Support

Atari and retro joystick wires are typically just 5 feet long. The main idea for wireless bluetooth support was to be able to sit back away from the TV while you played your classic games. So this is now possible with my new Bluetooth retro adapter! My PC will pair to the adapter with Bluetooth and I just plug my joysticks and paddles to the adapter and I am golden!

In my last blog, I showed a preview to this original prototype I made to prove it would work:

I used an ESP32 micro controller because it has built-in Bluetooth capabilities. By using a chargeable lipo battery (you can see it on the bottom), the right code, and the right wiring, the unit can be paired to your computer or phone via Bluetooth.

Joystick and Paddle Support

With the 2 game controller ports, you can connect 2 joysticks or even 2 paddles and a joystick at same time!

Getting paddles turned out to not be very simple because Atari paddles use mega ohm potentiometers and getting them to be jitter free needed a really decent analog to digital converter or use or an RC circuit for better precision. It was kind of fun playing old paddle games like Breakout.

Additional buttons

I decided to get a bit more fancy and added additional buttons on the device that could be mapped to simulate additional buttons on the joysticks. This is great because having the extra buttons will be useful to map to things like Start, Select, Reset, etc..

I also added a small screen to see immediate feedback of the Joysticks, paddle, and the buttons on the device! In the photo above I have connected a dual paddle controller to the port on the right and the screen shows 2 half circles for that port. As I move the paddles the dials move on the screen. Real-time information is sent to the PC with built-in bluetooth and my PC sees the joysticks and paddles as game controllers.

I designed a nice case with Fusion 360 and added a charging circuit for the battery and with a few sleepless nights getting the code to work, finally had success.

Buy one here

You can buy one here on sale and proceeds go to charity since I just do this for fun.

Video Overview

Programming Retro

Atari Retro Joystick USB adapter – Make or Buy – 2 and 4 ports

I recently built a Raspberry Pi 4 unit with Retro Pi and Emulation Station to check out its performance for retro gaming and when I got the Atari 800 emulation to work, it brought back many childhood memories of my first real PC. Games like Star Raiders and M.U.L.E. were well ahead of their time and to get the true experience, they have to be played with real Atari joysticks!

Star Raiders and M.U.L.E. on Atari 800

For past few months, I spent a good amount of time programming micro-controllers for IoT devices for my work projects and I thought about the possibility of using a micro-controllers to adapt Atari Joysticks to a PC so they can be seen as regular PC Gamepads.

I looked online and found some classic joysticks that came with the Atari Game Console Flashback unit for $15 on eBay and decided to give it a shot.

I checked out the Pin Diagrams for the joysticks and it seemed simple enough as they are basically 5 switches (1 for each direction and 1 fire button). Since I wanted at least 2 Joysticks connected for multiplayer games, I needed at least 10 IO ports to connect the 5 switches of each joystick.

Joystick Pins

I decided to use an Arduino Pro Micro controller since it was only $4, had plenty of IO ports, and most importantly it had a USB port that can communicate with PCs as a HID device.


I created a circuit design on EasyEDA so I could later order a PC baord but initially I created a prototype using PCS Prototype Boards you can get from Amazon or Aliexpress for pennies.

I ordered a few DB9 male connectors where the I could plug the joysticks into and put the parts on the board and soldered the connections.

I wrote some code in Arduino and after several attempts and figuring out custom board files for naming, finally had success. You can get the Dual joystick code from here.

If you are wondering how the animation below shows 5 button working, its not related to directions.. keep reading as there are multi button Atari joysticks.

Next. I decided to make an enclosure for it using my 3D printer! I drew it up in Fusion 360 and printed the top and bottom and made quite a tight fit.

I was finished with first working prototype. Next I refined it to a smaller version with a professionally made circuit board so its more reliable, no jumper wires, and less soldering. So its basically done.

Fusion 360 Design

Download STL files here.

But wait, M.U.L.E. is best with 4 players and I had to find a way to get it done so I could play with my nephews. One way was just to build another one taking up 2 USB ports and double the parts, and another was to challenge myself to do a 4 player design with a single USB port. So I did both 🙂

For the 4 port unit, I needed more ports so I decided to use a I2C I/O extender that can extend 2 GPIO pins to 16 using serial communication. I also wanted to support the modified Joysticks that have the extra Start, Select, Menu, and a few more button. Here is the circuit diagram and the outcome.

It worked great and I can tell you we had an amazing time playing 4 player M.U.L.E. ! So give it a shot and make one. You can get the code here.

If you rather just buy one from me, you can get it below. All net proceeds go to charity.

Next blog post, I will show you how I made a wireless version! It was not easy to get more than 1 joystick to work with a single device Bluetooth connection but I finally did it! The code was intense. Take a peek:

Prototype of Bluetooth version. Topic of future blog.

Very cool with no wires so I can sit back far from the TV and still play. Will be working on getting a commercial one out soon. Stay tuned!

UPDATE: Bluetooth Version released. See:

UPDATE: 4 port Plus version supporting Paddles, 7800 dual fire controllers, and real-time feedback on builtin screen released. See:

Video walk through of this post is below.

General Programming

Eight Constitution Medicine APP

Eight Constitution Medicine (ECM) is a comprehensive system of healing that has been proven effective for over 2500 years.  It is one of the fastest growing health care modalities today.

Why does one get tired after eating a meal? Why is one allergic to a particular food or medication and others are not?  Why does one get angry easily but another is calm from the moment they were born? The answer to these and similar questions is that each person’s make-up (also known as constitution), is different.

Everyone is born with a different constitution based on their genetics and physiology being either like their mother or father, as far as the relative strength and weaknesses of their organs.  People with the same disease or condition react differently to a food or a medication.  This is because of their constitution.

In ECM, a specialized pulse taking technique is used to diagnose your constitution (your make up) to identify what your strengths and weaknesses are (which appear inherently in the organ system, shape, character, personality, etc.).

There are 8 known constitutions: HepatoniaCholecystoniaPancreotoniaGastrotoniaPulmotoniaColonotoniaRenotonia, and Vesicotonia.

Your constitution will dictate what food groups to eat or avoid to help your body to heal itself. By following the right food regimen based on your constitution, you can help strengthen the weak and the deficient, or balance the overactive and the excess condition that you have.

Each constitution’s food intake plan is categorized in 3 groups based on the energetic nature and the effect of the foods on the body as follows

  • Good for You: Foods that are most beneficial for your health. Consuming them balances your organ system.
  • Better to Avoid: Food that you should eat in moderation and rarely, and  should not be a large portion of any meal.
  • Bad for You: Foods that are harmful to your well- being, and contribute to your illness.

If you do not know what your Constitution is, contact Verity and setup an appointment to have them examine you and determine your constitution.

Here at iCode,  we developed a mobile application that lets individuals  quickly lookup foods and displays the properties, nature, and effectiveness  as they relate to their specific constitution.


Risk dice roller

Here is a simple mobile app I helped my son write. He is a big Risk fan and this seemed like a great way for him to get introduced to android development.

Risk Dice Roller app is designed to replace dice needed for the original risk board game. It automates the rolling process and keeps history and statistics of each players rolls. You can even automate larger battles and watch as your large army takes on the defenders.  It can be really fun to compare player stats and its effect on the outcome of the game.


MS SQL query to Find Columns or Fields in Database

If you need to locate a field in a large database and you don’t know what table the filed is or not really sure of the exact spelling of the field, you can use this simple query to search for fields names in a database.

SELECT AS table_name, 
SCHEMA_NAME(schema_id) AS schema_name, AS column_name
FROM sys.tables AS t
WHERE LIKE '%Your_Field_Name%'
ORDER BY schema_name, table_name

Inject onload javascript for aspx master page

1. Add reference to HtmlControls on top of your cs file

using System.Web.UI.HtmlControls;

2. In your Page_Load function of the .cs file add

((HtmlGenericControl) this.Page.Master.FindControl(“PageBody”)).Attributes.Add(“onload”, “load()”);

3. Make sure your master page BODY has the the matching id from above. in this case:

ID=”PageBody” runat=”server”

4. In your aspx file, add you load function.


document.getElementById in with Master Pages

Using JavaScript to locate controls in pages that are linked to master pages can be tricky.  This is because the reassigns control IDs dynamically and the names change.

A simple solution is to use inline Tags.

For Example:

Instead for using:


try using:



c# function for a Bezier Curve

The Bezier Curve formula below can be used to define smooth curves between points in space using line handlers (line P0 to P1 and line P2 to P3).

P(t) = (1-t)^3P0 + 3(1-t)^2tP1 + 3(1-t)t^2P2 + t^3P3

At  t=0 you will be at p0, and at t=1 you will be at p3.

The function below is a C# implementation of the formula return the X and Y coordinates of a position on the curve for a given Time (t) and the 4 points that define the Bezier Curve.    

You can easily extend this to connect multiple curves to each other (multi-segmented path). You can do this simply by making p0 of subsequent segments equal p3 of the prior segment.

Include this function in your c# projects to create smooth curves.

C# Code Sample:

private Vector2 GetPoint(float t, Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3)
  float cx = 3 * (p1.X - p0.X);
  float cy = 3 * (p1.Y - p0.Y);
  float bx = 3 * (p2.X - p1.X) - cx;
  float by = 3 * (p2.Y - p1.Y) - cy;
  float ax = p3.X - p0.X - cx - bx;
  float ay = p3.Y - p0.Y - cy - by;
  float Cube = t * t * t;
  float Square = t * t;

  float resX = (ax * Cube) + (bx * Square) + (cx * t) + p0.X;
  float resY = (ay * Cube) + (by * Square) + (cy * t) + p0.Y;

  return new Vector2(resX, resY);

To use the function, simply pass in the 4 point and a time (between 0 and 1).  To draw the curve, try calling this function from a for loop that looks something like this:

// preset your p0,p1,p2,p3

Vector2 PlotPoint;
for (float t = 0;  t <= 1.0f; t += 0.01f)
   PlotPoint = GetPoint(t, p0, p1, p2, p3);

   // now call some function to plot the PlotPoint

This basically starts you at p0 when time t is zero and at each increment of time +0.01 you will slowly move on the curve towards p3.

So to give you an idea of how this was used by my son in one of his games, watch the video below

  • Note these are circular Paths each withe 3 segments. Each segment is a 4 point Bezier calculation.
  • p3 of the each segment is common to p0 of next each segment.
  • To make the circular, p3 of last segment must be same as p0 of 1st segment.
  • p2 and p3 of each segment must be on a strait line with p0 and p1 or the next segment. (this give you the double handles for each point)

So this means:

  • If a path point was moved by user, you must also move left and right control handler points by same deltas
  • If left handler moved, must also move corresponding path point so it intersects line to other handler at mid point
  • If right handler moved, must also move corresponding path point so it intersects line to other handler at mid point

Good luck.