Examples

 

Read Potentiometer and Button
Boards: Master, valve board, and input board
Tube connections: Connect the valves as shown in the video

The Pneuduino input board contains a potentiometer and a button. This example shows how to read these input devices and use the input data to control valve operation. The potentiometer measures the knob’s angular position, and `readPot()` returns an integer between 0 and 63. The button state can be retrieved with `readButton(0)`, which returns `true` when the button is pressed and `false` otherwise.

In this example, the left valve is pulse-width modulated at a period of 200ms. The potentiometer’s position controls the width of the pulse, adjusting the proportion of time the valve is turned on. The right valve is actuated simply when the button is pressed.

========================================

 

Three-state Operation
Boards: Master, valve board, and input board
Tube connections: Connect the valves as shown in the video

This example demonstrates the Pneuduino library’s ability to coordinate the two valves on a board to achieve three states — inflating, deflating, and holding pressure. To start, connect the left valve’s output port to an inflatable. Connect the left valve’s supply port to the compressed air supply. Finally, connect the exhaust ports of the two valves together.

In this example, pressing the button will toggle between the three states. When the inflate function is called, the left valve is turned on to allow compressed air to flow in. When hold is called, the left valve is turned off, blocking new air from coming in, and the right valve is turned on, blocking air from exhausting out. Lastly, when deflate is called, both valves are turned off, allowing air from the inflatable to flow back into the left valve, through the connected exhaust ports, and out the right valve.

========================================

 

Pressure Regulation
Boards: Master, valve board, and input board
Tube connections: Connect tubes as shown in the video

The Pneuduino library has the ability to use the onboard pressure sensor as a software pressure regulator, automatically switching the valves to inflate, deflate, or hold as necessary to maintain a pressure. The tube connections for this feature are mostly the same as for the previous example, with the exception that the output tube goes to a T connector. One branch of the T connects to the inflatable, while the other branch connects to the pressure sensor.

When the code is run, the potentiometer’s position is used to set the desired pressure. The Pneuduino library handles the control of the valves automatically. Best results are achieved with a larger inflatable, as a greater volume of air tends to result in a more stable pressure.

========================================

 

I2C Gesture Sensor
Boards: Master, valve board, and Grove extension board
Tube connections:  Connect the valves as shown in the video

Pneuduino has an extension board that allows Grove I2C sensors to be easily incorporated into the system. On the software side, the Pneuduino library can be used together with sensor libraries, allowing sensor data to easily control pneumatic functions. This example shows the use of the Grove Gesture v1.0 sensor to control inflation and deflation.

Plug the gesture sensor into the extension board. Connect the output of the left valve to the inflatable, and connect the supply port to the compressed air supply. When the gesture sensor detects your hand moving towards it, the valve is opened. Air flows into the inflatable, simulating the effect of being pushed by your hand. When your hand moves away from the sensor, air is released.

========================================

 

I2C Touch Sensor
Boards: Master, valve board, and Grove extension board
Tube connections: Same as the Gesture Sensor example

The Grove I2C Touch Sensor is a multi-channel capacitive touch sensor that allows for easy tactile input and feedback. It is able to detect touch through thin surfaces, meaning that it can be placed inside an inflatable. In this example, we demonstrate how to use the touch sensor’s library. After initializing in setup(), we update the sensor’s state with a call to getTouchState(). The new data is written to the touched variable. When a touch on any channel is observed, touched will be non-zero. (To see the specific channel(s), the n-th bit will be set to 1 if the n-th channel is touched.) We open the valve for a brief amount of time whenever a touch is observed.

========================================

 

EMG Sensor
Boards: Master, valve board, Grove extension board, and Grove I2C ADC
Tube connections: Same as the Gesture Sensor example

The EMG Sensor is one of the more complicated analog sensors to use with Pneuduino. Like all analog sensors, it must be read through the Grove I2C ADC. This sensor detects the small electrical signals in human muscles and amplifies them to a readable analog voltage. Attach the sensor’s electrodes to your arm, and run the example code. Relax your arm and hold still while the sensor’s output settles. Now forcefully move your arm, and the sensor should trigger a positive reading. The EMG sensor is very sensitive and sometimes unstable. Adjusting the value of the threshold is likely to be necessary in order for this example to function properly.

========================================

 

BlinkM LED Driver
Boards: Master, valve board, and Grove extension board
Tube connections: Connect tubes as in the Pressure Regulation example.

The BlinkM MaxM is a I2C LED driver that can control three large onboard LEDs or any common-anode RGB LED strip, with the option to use an external power input. In order to use the BlinkM MaxM, it is necessary to solder a Grove cable onto the board’s input pins. Connect black to -, red to +, white to d, and yellow to c. Plug the other end of the cable into Pneuduino’s Grove extension board.

The BlinkM MaxM has the ability to have its I2C address reset through an I2C command. The board’s default address is 0x9, which conflicts with a Pneuduino valve board. In the example code, the SET_BLINKM_ADDRESS define can be used to create a program to reset the board’s address. With a new BlinkM board, this address-setting program must be run once before the regular code can be used.

Every time loop() is run, the code for this example checks the pressure reading against a threshold pressure. If the pressure is below this threshold, we tell the Pneuduino library to continue maintaining a pressure slighly below the threshold. We turn off the LED and store a random color. When the inflatable is squeezed, the pressure will rise above the threshold. Now, we hold pressure and set the LED’s brightness proportionally to the pressure. Thus, the LEDs brighten up the harder the inflatable is squeezed. When the inflatable is released, the pressure falls below the threshold, and the situation repeats.

========================================

 

Wave
Boards: Master and at least 2 valve boards
Tube connections: Connect all supply ports to the air supply. Connect each output port to an inflatable.

In this example, we demonstrate an advanced valve timing sequence, where we inflate and deflate a row of inflatables in sequence. We want each valve to turn on shortly after its neighbor has turned on, thus propagating a “wave” motion down the row of inflatables. This style of motion can be applied to propel “crawling” pneumatic robots. The code for this example is extendable to arbitrary numbers of valve boards.

We first designate the length of an entire wave cycle. Every time a new cycle begins, we compute the on and off times for each individual valve, which depends on the valve’s position, the time offset between valves, and the duration we want each valve to stay on. This information is stored and used on subsequent loop() iterations to open and close valves when appropriate. When the end of the wave cycle occurs, the whole process repeats.