Send values to a microcontroller digital output

The DigitalOut widget controls the digital output ports on a microcontroller, turning them on or off. These ports are typically used to control LEDS, relays (to control high power devices such as 110 volt lights) or motors.

The DigitalOut widget turns the digital output port on within a defined range of inputSource values, as set by the from and to settings. So for example, if an AnalogIn was monitoring a knob (potentiometer) used to sense how far a door was open, and the “open” position ranged from 500-700, the DigitalOut could turn on an LED in that position by setting its from to 500 and the to setting to 700.

On Screen Features

  • IN:Shows the values coming from the inputSource as well as the instance name of the inputSource
  • OUT: Shows the output value visually, either on or off. Also shows the type of controller, and the digital output port on the controller. You can click on the circle icon to manually to turn the power on or off.
  • CONNECT: Establishes a connection with the microcontroller



  • controller – Determines which kind of device the widget communicates with: Arduino, iotnREST, OSC, hubFeed or serial. 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 iotnREST.
  • controllerOutputNum – Sets the output port on the controller – starts at 0 to use the first port on the controller.
  • controllerPort – Sets the IP Port used to communicate with OSC
  • hubFeedName – The name of the Hub feed to send to. See also the AnalogOut for sending a hub feed, and the HubFeed tutorial.
  • 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 simply by pressing the backslash key “\”.
  • multiplier – This number is multiplied with the raw input number from the controller, if set to OSC, hubFeed, or accelerometer. 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, e.g. by setting multiplier to 1023.
  • remoteHubIP – This sets the IP address of the Hub where the widget will get input values from a microcontroller. Normally this would be 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.
  • 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.
  • threshold:  If the input value is equal to or greater than this number (500 by default) then the widget will turn on the output port on the microcontroller.
  • 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).
  • 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).

Code Interface

sendOutput(value:int, port:int)

The sendOutput function allows code to send out arbitrary values to any port on the microcontroller.

myDigitalOut.sendOutput(211, 1);


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



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


Last modified July 6th, 2014