Skip to content

6 – ServoOutputHelper component

ServoOutputHelper points one servo at an angle. It has two methods:

Method Input What it does
SetAngle(float) Degrees, 0–180 Points the servo at that angle. Values outside 0–180 are clamped.
SetValue01(float) 0–1 Moves between Min Angle (0) and Max Angle (1). Fits straight onto AnalogInputEvent and UI sliders.
  • Wire the servo with its signal on D3.
  • In Set Up Arduino, set D3 to Servo Out and write it into your profile.
  1. Create an empty GameObject, for example Servo.
  2. Add Component > SerialInputBridge > Servo Output Helper.
  3. Set Pin to 3.
  4. Optional: narrow Min Angle and Max Angle if your mechanism shouldn’t use the full 0–180° range.
  1. On your AnalogInputEvent for A0, click + under On Value Changed.
  2. Drag in the Servo GameObject and choose ServoOutputHelper > SetValue01 under Dynamic float.

Press Play and turn the potentiometer. The servo follows.

Add a UI > Slider (Min 0, Max 1) and point its On Value Changed at SetValue01 (Dynamic float). For degrees, set the slider to 0–180 and use SetAngle instead.

The package includes an example script, ServoAngleOut, in Assets/SerialInputBridge/fromtutorialvideos/. It reads a number from a TextMeshPro input field and calls SetAngle.

  1. Add a UI > Input Field - TextMeshPro.
  2. Add ServoAngleOut to a GameObject. Drag the Servo GameObject into Servo and the input field into Angle Input Field.
  3. On the input field, under On End Edit (String), click +, drag in the ServoAngleOut GameObject and choose ServoAngleOut > SetAngleFromInput under Dynamic string.

Press Play, type 90 and press Enter.

Wire an HW-479 RGB LED module →