Introduction: Arduino Mechanotronic Human Pain Reflex

Due to their simplicity, reflex circuits are an obvious place to start when trying to model the nervous system. I chose to use the thermal pain reflex for my first project. In this pain reflex, a painful stimulus such as an open flame or stove burner activates predominantly Aδ afferent fibers. That painful stimulus is encoded as a high frequency of action potentials and processed in excitatory and inhibitory neurons in the spinal cord. The output from these interneurons leads to an increase in action potentials sent to the biceps muscle and a decrease in action potentials sent to the triceps muscle. Modulating the normally tonic contraction in these antagonistic muscles allows for contraction of the biceps and a quick removal of the hand from the painful heat stimulus.

Step 1: Inventory

Items you will need for this Instructable:

Air tank:

Hand for your homemade arm (if you don't buy the skeleton arm):

White wire loom:

One way valves:

2x 3 way solenoids valves:

2 way solenoid valve:

2x mini air regulators:

Assorted 1/4" npt/npt and npt/barb fittings: is a good site for much of this

Arduino starter kit (if you don't have one and some electronic components already): There are others out there, this one contains most if not all of the components you'll need to build the circuit, including the TMP36 temperature sensor.

Project box for your "spinal cord":

12 volt battery:

These are the items that I used for the project. There are many ways to save $$$ by simplifying the simulator or by using other parts that you may have or that are cheaper but sufficient. For instance, you could get rid of the triceps muscle and just use the bicep muscle to provide contraction, which reduces the physiological relevance, but it also eliminates the need for the 2nd 3 way solenoid, the 2nd regulator, and other parts as well.

Step 2: Buy or Build Your Own Skeleton Arm

I bought a realistic arm from here, but you could make a suitable model from a few pieces of wood and a hinge. This page has a good description of how that could be done.

Step 3: Make Some Air Muscles for Your Biceps and Triceps

Pneumatic actuators were first developed in the 1950s to aid polio victims who had lost the control of a limb. These actuators have gotten popular recently in the robotics and mechanotronics fields. A great Instructable already exists detailing precisely how to create these muscles, which I followed to build my biceps and triceps muscles. The skeleton arm I bought had wire mounting points for the muscles at the top and bottom, if you make your own you would need to add eyehooks or something similar for mounting of the muscles.

Step 4: Connect Your Air Supply and Solenoids

I used a quick disconnect fitting to connect the solenoids and pressure regulators to the air tank. From the quick disconnect, the Y fitting next provides air to the regulators. One regulator is used to control a 3 way solenoid which provides low pressure air to both the biceps and triceps muscle to simulate the tonic, balanced low level of skeletal muscle activity that is common in antagonist muscles around a relaxed joint. The other regulator provides air to a second 3 way solenoid valve, which controls higher pressure air movement to the biceps muscle to provide for a quick forearm contraction, and then to a 2 way solenoid valve which prevents air from exiting the system during the tonic biceps/triceps low pressure contraction. Both solenoids have 1/4" NPT to 3/16" barb fittings screwed into their outputs, and the 0.170" tubing recommended in the air muscles Instructable is used to connect the solenoids to the muscles, as shown in the image.

In the low pressure, tonic biceps/triceps contraction pathway, I set the pressure regulator at ~10 psi. In the high pressure, bicep contraction/hand removal pathway, I set the pressure regulator at ~40-50 psi. Above that, there isn't much change in bicep contraction amount or speed.

Step 5: Build Your Spinal Cord and Write the Arduino Code

The Fritzing diagram above details the parts and connections necessary to hook up our temperature sensor and solenoids to the "spinal cord", the brains (pun intended) of our system. The 12 volt NiMH battery sits underneath the breadboard and SparkFun RedBoard inside of the project box. The temperature sensor is not located on the breadboard as shown in the Fritzing diagram, but is attached to the skeleton hand as shown in the 3rd image above. This allows for the flame to be applied near the hand to best simulate the temperature pain reflex.

The code I used is pasted below. It's not the most elegant solution (e.g., I used delay instead of millis to keep it simple), but it works:

const int highSolenoid = 7; //input from high pressure regulator/solenoid combo
const int lowSolenoid = 8; //input from low pressure regulator/solenoid combo

const int releaseSolenoid = 4; //solenoid to release air from bicep

const int tempPin = A0;

int sensorValue;

int tempF;

void setup() {

pinMode(highSolenoid, OUTPUT);

pinMode(lowSolenoid, OUTPUT);

pinMode(releaseSolenoid, OUTPUT);



void loop()


sensorValue = analogRead(tempPin); // Read pressure sensor

int tempF = ((sensorValue * 4.887585532746823)/10);


Serial.print(" Temp ");

Serial.println(tempF, DEC);


if (tempF > 85)


digitalWrite (lowSolenoid, LOW);

delay (100);

digitalWrite(releaseSolenoid, HIGH); // open release solenoid so bicep can be contracted digitalWrite(highSolenoid, HIGH); //if the temp goes above 85F, the high solenoid is opened, simulating bicep contraction and quick and removal

delay (5000);

digitalWrite(highSolenoid, LOW); //stop bicep contraction

delay (1000); //gives time for air to be released from bicep

digitalWrite(releaseSolenoid, LOW);

delay (100); //time for release solenoid to close before activating tonic bicep/tricep contraction again

digitalWrite(lowSolenoid, HIGH);

delay (8000);




digitalWrite(lowSolenoid, HIGH);

digitalWrite(highSolenoid, LOW);


Step 6: Test It Out!