Skip to content

Setting Pin and Device Values

In this section, we discuss writing data to:

  • Digital pins.
  • Digital pin PWM output (Analog Write).
  • Servo motors.

Note: I2C devices are discussed in the next section of this guide.

analog_write

 def analog_write(self, pin, value)

    Set the specified pin to the specified value.

    :param pin: arduino pin number

    :param value: pin value (0-255)

Examples:

  1. telemetrix: fade
  2. telemetrix-aio: fade

digital_write

  def digital_write(self, pin, value)

    Set the specified pin to the specified value.

    :param pin: arduino pin number

    :param value: pin value (1 or 0)

Examples:

  1. telemetrix: blink
  2. telemetrix-aio: blink

servo_write

 def servo_write(self, pin_number, angle)

    Set a servo attached to a pin to a given angle.

    :param pin_number: pin

    :param angle: angle (0-180)

Examples:

  1. telemetrix: servo
  2. telemetrix-aio: servo

Notes:

For an angular servo, the position parameter is set between 0 and 180 (degrees). For a continuous servo, 0 is full-speed in one direction, 180 is full speed in the other, and a value near 90 is no movement.