AnalogIn
The AnalogIn connects to the analog inputs of a microcontroller or other system and can process the incoming values as they come in. If connected to a microcontroller, AnalogIn will receive and display the values coming from a sensor attached to the selected port on the microcontroller, for example Arduino port 0 (the first analog input port). If the controller parameter is set to inputSource, OSC, or hubFeed, the values will come from other software. Once values are received, AnalogIn will process the values (e.g. scaling them within a range), and output them for use by other widgets.
The default range for analog inputs for most microcontrollers is 0 – 1023, which can be scaled any range desired by setting the min and max numbers. AnalogIn also has a fader knob which allows the user to simulate the values of a sensor coming in, making it possible to test the project without external hardware hooked up.
On Screen Features
- connect – A button in the top right corner, when on, reads data from the sensor at the selected port. When off, use the slider to set the value. The off mode is useful for when you don’t have the sensor and/or microcontroller hooked up, but still want to test what would happen. You can simulate the operation of the sensor by dragging the knob up and down.
- in – A display of the unprocessed data coming from the sensor
- ceiling – The highest raw value processed. Values higher than this value are ignored. Useful if your application uses a limited range of the sensor. Can also be used to extend beyond the normal 1023 maximum range.
- floor – The lowest raw value processed. Note that the CEILING and FLOOR values will be scaled to the MAX and MIN values. So if ceiling is set to 800, floor is set to 200, max is set to 100 and min is set to 0, the values from 800 to 200 will be scaled from 100 to 0. Can also be set to a negative number for sources such as OSC that may have negative values.
- max – Sets the highest value output. The highest input value (after ceiling and floor) is scaled to this value
- min – Sets the lowest value output. The lowest input value (after ceiling and floor) is scaled to this value
- smooth – When on, performs a median filter on the raw sensor readings so that the processed values are less jittery. This is helpful because many sensors produce rough readings that change more than you want. Adjust the smoothingBufferSize parameter for more or less smoothing.
- ease – When on, performs a real-time easing function on the input so that the output follows the input in a smooth, seemingly natural motion that’s similar to how a real physical object would move and exhibit momentum and react to friction.
- invert – Makes a high raw value produce a low output value and visa versa. Useful for reversing the effect of a sensor
- out – The value output by the widget after all processing is applied
Parameters
- controller – Determines which kind of controller the widget communicates with Arduino, Make, OSC, Xbee, inputSource (inputSource means that the widget will get input from another widget with the name set in the inputSource parameter), or hubFeed (see below explanation for hubFeedName)
- controllerInputNum - Sets the analog input port on the controller – starts at 0 to use the first port on the controller. When using an inputSource such as OSC that may have multiple values, this number sets the argument used. E.g. in /acceleration/xyz 0.1 0.2 0.3, setting controllerInputNum to 2 would get the third argument for the Z value of 0.3.
- controllerIP – Sets the IP address used to communicate with the Make Controller, or OSC. NOTE: The default controllerIP address used for the Make is 192.168.0.200. This works with the older, larger Make Controller. For the newer, smaller Make Controller, the default address on the Make seems to be 192.168.0.201. So if you find AnalogInput is not communicating with the Make Controller, try setting the controllerIP to 192.168.0.201.
- controllerPort - Sets the IP Port used to communicate with the Make Controller in combination with the CONTROLLER IP. By default this is 10000.
- easeAmount – Controls the amount of easing that’s applied if the ease button is ON.
- hubFeedName – The name of the Hub feed to listen to. The hubFeed controller option allows the application to accept input from any arbitrary source that sends a feed to the Hub. For example, a remote computer (or in the future a tablet) can send values to your hub, and you can accept them using the AnalogIn widget. See also the AnalogOut for sending a hub feed. If you want to get a hub feed from a remote computer running its own hub, set the remoteHubIP parameter to the IP address of that computer. The oscMultiplier also applies to a hubFeed.
- inputSource - Used if “inputSource” is selected in the CONTROLLER parameter. In this case, the values processed by AnalogInput will come from another widget with the name specified in inputSource.
- invisible: If set to “true” or checked, the widget will disappear when the Flash movie is run - NOTE: you can make all the widgets invisible interactively when the Flash moving is running simply by pressing the backslash key “\”.
- oscMultiplier - Used when the controller is set to OSC. Many OSC devices and software provide fractional values from 0-1. To work with other toolkit widgets, these numbers should be scaled up to an integer range. By setting oscMultipler, any number sent by the OSC source will be multiplied by this number. This parameter also applies to a hubFeed input.
- oscString - This is the OSC message that AnalogIn will listen for. For example “/slider/1″ will listen for the message from iPhone app OSCemote’s first slider.
- remoteHubIP - This sets the IP address of the Hub where the widget will get input values from a microcontroller. Normally this would be 127.0.0.1 for the Hub running locally. But if you want to receive values from a Hub and microcontroller running on a remote computer, change this IP to the address of the remote computer. In this way, widgets on multiple computers can access sensor data from a remote computer with sensors attached. Note that even if you are using a remote Hub, the Hub application must also be running locally on the same machine as the widgets.
- sampleRate - Sets the number of times per second the microcontroller port is queried for its value. In some cases, reducing this may improve performance.
- serialPort - For widgets set to communicate with an Arduino or XBee, the USB serial port name that the device is connected to. On the Mac, you can leave the default (/dev/cu.usb*) if only one device is hooked up. On the PC, replace this with the COM port used, e.g. COM7. For more detailed info on how to set this parameter, see the common features for all widgets discussion here.
- smoothAmount – Sets the size of the buffer for the smoothing. the larger the number, the more smooth the processed values will be. but the other effect is that the processed values will have a lag time from the actual sensor data. This lag time will increase with the buffer size.
- xbeeRemoteID - When using the Xbees, use this number to indicate which remote Xbee you wish to communicate with. (note, this is a decimal number, when configureing the XBee in XCTU the ID number you enter there is in hexedecimal)…
Working with the Arduino
see the Arduino setup information on this page.
Working with the Make Controller
Please see the Make ethernet communications documentation here.
Working with the Xbee
Please see the XBee setup information on this page.
Working with OSC
AnalogIn can receive OSC messages from any device, and will read the a value after the main OSC string if the string matches what’s specified in oscString. It will multiply this value by the oscMultiplier specified in the widget parameters. So for example, if you use the iPhone app OSCemote, the Sliders send a message such as:
/slider/1 0.3
In this case, you would set the oscString parameter to “/slider/1″, and the oscMultiplier to 1023 (the default). AnalogIn will then convert the numbers OSCemote sends (which are between 0 and 1), and convert them to the full range of the widget (0-1023).
For more information, see the OSC tutorial.
Last modified May 24th, 2011

