AnalogOut

Send values to a PWM output on an Arduino, or to iotnREST, OSC, hubFeed, or serial device

The AnalogOut widget sends a continuous range of numbers to its output. It can control the PWM (Pulse Width Modulation) outputs of a microcontroller, or send a range of numbers to other devices or software.

PWM outputs are typically used to control the brightness of LEDs or speed of motor by setting the power output of the PWM port, where a higher number delivers more power. For the Arduino, input values ranging from 0-1023 are scaled to 0-255.

When the AnalogOut controller is set to iotnREST, OSC, hubFeed or serial, values from the inputSource are sent directly out to those protocols, and can be fractional. In addition, if using the sendOutput() code interface, multiple values and non-numeric values can be sent out. See more info on this below in the Code Interface section.

In some cases, you may want to shape the output so that it follows an envelope, ramping up and down as its input rises. This functionality is available in a separate processing widget call Envelope, which would receive values and the AnalogOut widget would get its values from Envelope.

On Screen Features

  • connect: Button at the top-right of the widget establishes a connection with the microcontroller

Parameters

  • controller: Determines which kind of device the widget communicates with: Arduino, iotnREST, OSC, hubFeed or serial. Use hubFeed (tutorial) to send a feed of values to a hub, which can be read by an AnalogIn widget set to the hubFeed with the same hubFeedName, even one one running on a different computer or mobile device (you’ll need to set the remoteHubIP correctly, or be using MobileControl). Use serial (tutorial) to send output to any device that can receive serial input.
  • controllerIP: Sets the IP address used to communicate with OSC or the Make Controller
  • controllerOutputNum: The PWM port on the microcontroller. For the Arduino Duemilanove and UNO, use ports 3,5,6,10,11 or 12 (for other Arduinos, check your documentation). For the Make Controller, should be 0-3.
  • controllerPort: Sets the IP Port used to communicate with OSC or the Make Controller in combination with the CONTROLLER IP. By default this is 10000.
  • hubFeedName: The name of the Hub feed we’re creating. The hubFeed controller option allows the application to send a feed of values that another widget or different computer can listen to. See the AnalogIn widget for receiving a hub feed, and the HubFeed tutorial. If you want to send a hub feed to a remote computer running its own hub, set the remoteHubIP parameter to the IP address of that computer.
  • inputSource: The instance name of the source the widget listens to, e.g AnalogIn.
  • 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 by pressing the backslash key “\”
  • multiplier: Used when the controller is set to OSC and HubFeed. Many OSC devices and software require fractional values from 0-1. To provide the appropriate numbers for the output to the device/software the toolkit numbers may need to be turned into the appropriate fractional numbers. By setting multiplier, any number coming into the AnalogOut will be multiplied by this number and output. E.g. set the multiplier to 0.001 to change numbers in the range 0-1000 to a range of 0-1. To be exact for numbers ranging from 0-1023, use a multiplier of 0.0009775171.
  • remoteHubIP: This sets the IP address of the Hub where the widget will send values. Normally this would be 127.0.0.1 for the Hub running locally. But set this to the IP address of another computer running a HUB, e.g. to access devices connected to that computer. 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.
  • roundOutput: If checked, forces the output values to be integers. If not checked, values may be fractional.
  • 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.’
  • urlString: This text is used for iotnREST and OSC inputs. For iotnREST, this is the URL sent to the remote device. For OSC, this is the OSC message that AnalogIn will listen for (e.g. “/slider/1” will listen for the message from iPhone app OSCemote’s first slider).

Working with the Arduino or Make microcontrollers

See the Arduino setup information on this page, or the Make ethernet communications documentation here

Working with OSC

AnalogOut can send OSC messages to any device using the OSCstring parameter. It will multiply its output value by the multiplier parameter. For more information, see the OSC tutorial.

Working with Mobile devices

Tutorial on mobile devices.

Code Interface

The below examples assume an AnalogOut widget with an instance name of “myAnalogOut”

sendOutput(numericValue:Number)
sendOutput(listofValues:String)

Sends the values to the controller set in the parameters. If the value is a number, sends that single number out. If the controller is set to OSC or hubFeed, you can send a string of values that will all be sent out. NOTE: If you are sending multiple strings separated by spaces, you must include {curly braces} at the beginning and end of the overall string – see below example.

myAnalogOut.sendOutput(385); // works for all controllers to send value of 385
myAnalogOut.sendOutput("{385 200 10 644}") // works for OSC, hubFeed, and serial to send a set of values in one message

connectWidget()

Causes the widget to connect to the controller, the same result as using the connect button.

myAnalogOut.connectWidget();

disconnectWidget()

Causes the widget to connect to the controller, the same result as using the connect button.

myAnalogOut.disconnectWidget();

Last modified July 6th, 2014