Sensor and Processing Exercise for Motion Studies

 

In this lab you will be able to change aspects of simple shapes in real time using sensor inputs.  Sensors provided include potentiometers with knobs, light sensors, temperature sensors and heartbeat sensors.  The Make!Sense sensor interface board connects the sensors to your computer, and a custom Processing program is provided to allow the sensor values to control shapes on the screen.  The display window has been set to 960 by 450 pixels, which fits the 16:9 aspect ratio.

 

 

 

1. Download the Processing file https://www.dropbox.com/s/zpcwbrh67klm7ky/PrattGenericData.zip?dl=0

Unzip it into your Processing Documents folder.

 

2. Connect six potentiometer sensors to the red, white and black cables.  Red goes to "VCC", White goes to "OUT", and black goes to "GND".  Tape them down to the Foamcore board for stability.

 

3. Plug the white end of the cables into the two vertical rows of connectors on the board, at the left and right sides as you look at the board with the "MakeSense" label at the top left.  These are channels 0, 1, 2, 5, 6 and 7, 

 

4. Run the PrattGenericData Processing program.

 

5. There are 5 modes in the program, accessible by hitting the 1,2,3,4,5 numeric keys on your keyboard.  Each mode displays some realtime text on the screen that gives you some information about how the sensors are mapped, and what they do.  At any time you can press the "b" key to toggle the background erasing on or off.  You can also press the "t" key to toggle the text display on and off.

 

6.  You may replace the potentiometer sensors with photocells, thermistors or heartbeat sensor to explore these modalities.  The photocell reacts to light, the thermistor to breathing on it, and the heartbeat to your heart rate sensed through your earlobe.  The potentiometer has a range of a full 0 to 255 units.  Other sensors have different ranges, and the ranges can be seen in the text display to the left of the screen when you run the program.  The wiring for attaching other sensors to the cables is shown here:  http://www.makesense.co/#!sensors/c24jg

 

 

7. To tinker with the code, work only in the main file PrattGenericData and do not modify the two files labeled HID_Stuff or data_polling.   In each of the code areas for the five modes, there are code lines like this:

 

    shape1X = map(sensor_data_0, 0, 255, 0, width); // scaled to the entire width of the window

 

In this line of code we see that shape1's X location is being controlled by the sensor values coming in to channel 0 (top left white connector), and that that data is being mapped from the sensor's output range 0 to 255 units to the x values on the screen which run from 0 at the left to "width" at the right, which is the full pixel width of your Processing window.  If you replace the potentionmeter with a temperature or light sensor, you may need to adjust the first two numbers 0 and 255 with the low and high range of the sensor.  You can see these range numbers by watching the text on the screen change as you let more or less light fall on the photocell sensor, or breathe on the temperature sensor.  The photocell has a much wider range of values than the temperature sensor.  The heartbeat sensor actually has only two values: 0 and 255.

 

If you make a mistake in coding, and it's very easy to do that, you may not be able to easily recover from the errors.  The simplest fix is to close the file in Processing WITHOUT SAVING, and re-open it.  You can always re-download from the DropBox link.