The robot controller consists of the parts listed in Table
1. The Fritzing diagram in Figure 5 shows how simple the
robot controller’s circuit is, while Figure 6 shows the actual
While the NodeMCU Amica module is the central
component in the robot controller’s design, it is the
interface to the joystick that is the interesting part of the
circuit. For those who haven’t used a joystick before, the
particular joystick used in this design is comprised of two
potentiometers and a switch. As the joystick is moved left
and right, the horizontal potentiometer changes value. As
the joystick is moved forward and backward, the vertical
potentiometer changes values. The joystick’s switch closes if
the joystick is depressed, and opens when the joystick
is subsequently released.
In this design, the potentiometers are wired
between the 3. 3 VDC supply (from the NodeMCU
device) and ground, so the arm of the potentiometer
varies between these two values as the joystick is
moved. The analog-to-digital converter (ADC) in the
NodeMCU is a 10-bit converter, so input voltages in
the range of 0.0 to 3. 3 VDC result in converted values
between 0 and 1023.
A problem that came up was the joystick supplies two
analog signals, while the NodeMCU device has only a single
ADC input, A0. I got around this problem by using two
sections of a CD4066 CMOS quad bilateral switch. Each of
the four analog switches in these devices is controlled by a
separate control signal. When the control signal is high, a
low resistance path is established between the input and
output of the switch (i.e., the switch is on). When the
control signal is low, the switch turns off.
These analog switches are called bilateral because
signals can flow in either direction. For example, switch
section A has two signal connections: A in/out and A
out/in. Either one can be the input or the output.
I got around the single ADC input issue by turning
analog switch A on when reading the horizontal
joystick signal, then turning it off and analog switch
B on when reading the vertical joystick signal —
effectively giving the ADC two inputs. Software in
the NodeMCU device changes the analog switch
control signals back and forth while the joystick’s
position is being read. Currently, the joystick’s switch
is not being used, but it is wired to a GPIO line on
the NodeMCU device in case the software ever
wants to make use of it.
While the hardware for the robot controller is
relatively simple, the software to make it all work is
somewhat complex because there is a lot going on. The
software has to establish and maintain the wireless
connection between itself and the robot; it has to
continually read the position of the joystick and pass motor
control tokens over the link; and it has to monitor link
synchronization between the robot and itself.
While all this activity calls out for some sort of
multitasking to handle these multiple disparate tasks, we
don’t have that luxury on the NodeMCU. Instead, I
employed a Finite State Machine (FSM) to manage things.
Technically, a FSM is:
“A model of a computational system, consisting of a
set of states, a set of possible inputs, and a rule to map
each state to another state, or to itself, for any of the
Sounds daunting, but don’t let the definition scare you.
The operation is really quite simple. The operation of the
44 SERVO 05.2016
Figure 5. Robot controller Fritzing diagram shows how simple the
Figure 6. Robot
Item Description Source
Micro controller with Wi-Fi
CD4066B CMOS quad bilateral switch ebay.com, digikey.com, etc.
RGB LED Common cathode type “
Three Resistors 1K ohm 1/4 watt, 5% “
Thumb Joystick COM-09032 sparkfun.com
Misc. Wire, perf board, 14-pin IC socket, solder Junk box