Skip to main content


Air Pressure Controlled Movement

With Pneumatics we can make linear motion using air pressure and software controlled valves. The VEX system provides for single acting and double acting pistons. A single acting gives a push with air pressure, while the double acting can give a push or pull force with air. Mostly we use double acting, if we need only single we just use one side of the double acting.

Pneumatic set up

Pneumatic set up is shown in this image. The system requires a tank to store air, a manual valve to control the air. This image shows a system with 2 double acting pistons, each controlled by a solenoid valve.

Pneumatics Instructions

How to assemble and use the components of the VEX pneumatics system are shown in this Document.

The document gives detailed descriptions of each part and how to assemble them. If this is you first experience with pneumatics you must read this Document.

Code for Pneumatics

The code for the VEX pneumatics is basically telling the solenoid valve to switch from one position to another. This is done with a digital signal through the 3 wire ports of the V5 Brain. The method we use is


Where bool is either true or false. True will send the air one way, false will send it the other.


We first have to create an object of digital_out class in the robot configuration. This is now available in device set up .  Select three wire port and digital out.  You get this code in robotconfig.cpp.

digital_out dig1 = digital_out( Brain.ThreeWirePort.A);

This line creates an object named dig1, you can name it anything you want but just like naming motors it would be good if it is descriptive of what it is like claw or grabber. Brain.ThreeWirePort.A sets it as connected to port A you can use any of the available letters. If you have more than one solenoid you will certainly use different letters.

Once you do this you also need another line of code in robot-config.h

extern digital_out dig1;

this lets main know that you have this device configured. Once these lines are written click build to check and compile the code.

in main.cpp these lines can now be written in any function to control the pneumatics.

  wait(1000, msec);
  wait(1000, msec);

This code will just move the pneumatic cylinder from one position to the other after waiting a second between moves.

Driver Control

Here is a user control code that will let you move a pneumatic based on pushing buttons A or B

void driverControl() {
  while (true) {
    if (Controller1.ButtonA.pressing()) {
    } else if (Controller1.ButtonB.pressing()) {