j5.backends.console.j5.arduino module

Base backend for Arduino Uno and its derivatives.

class j5.backends.console.j5.arduino.ArduinoConsoleBackend(serial: str, console_class: Type[j5.backends.console.console.Console] = <class 'j5.backends.console.console.Console'>)[source]

Bases: j5.components.gpio_pin.GPIOPinInterface, j5.components.led.LEDInterface, j5.backends.backend.Backend

An abstract class to create console backends for different Arduinos.

firmware_version

The firmware version reported by the board.

Returns:firmware version reported by the board, if any.
get_gpio_pin_digital_state(identifier: int) → bool[source]

Get the last written state of a given GPIO pin.

Parameters:identifier – pin number
Returns:Last known digital state of the pin.
Raises:ValueError – pin is not in correct mode.
get_gpio_pin_mode(identifier: int) → j5.components.gpio_pin.GPIOPinMode[source]

Get the hardware mode of a GPIO pin.

Parameters:identifier – pin number.
Returns:mode of the pin.
get_led_state(identifier: int) → bool[source]

Get the state of an LED.

Parameters:identifier – LED identifier.
Returns:current state of the LED.
Raises:ValueError – invalid LED identifier.
read_gpio_pin_analogue_value(identifier: int) → float[source]

Read the scaled analogue value of a given GPIO pin.

Parameters:identifier – pin number
Returns:scaled analogue value of the pin.
Raises:ValueError – pin is not in correct mode.
read_gpio_pin_digital_state(identifier: int) → bool[source]

Read the digital state of a given GPIO pin.

Parameters:identifier – pin number
Returns:digital state of the pin.
Raises:ValueError – pin is not in correct mode.
set_gpio_pin_mode(identifier: int, pin_mode: j5.components.gpio_pin.GPIOPinMode) → None[source]

Set the hardware mode of a GPIO pin.

Parameters:
  • identifier – pin number to set.
  • pin_mode – mode to set the pin to.
set_led_state(identifier: int, state: bool) → None[source]

Set the state of an LED.

Parameters:
  • identifier – LED identifier.
  • state – desired state of the LED.
Raises:

ValueError – invalid LED identifier.

write_gpio_pin_dac_value(identifier: int, scaled_value: float) → None[source]

Write a scaled analogue value to the DAC on a given GPIO pin.

Parameters:
  • identifier – pin number
  • scaled_value – scaled analogue value to write
Raises:

NotImplementedError – Arduino Uno does not have a DAC.

write_gpio_pin_digital_state(identifier: int, state: bool) → None[source]

Write to the digital state of a GPIO pin.

Parameters:
  • identifier – pin number
  • state – desired digital state.
Raises:

ValueError – pin is not in correct mode.

write_gpio_pin_pwm_value(identifier: int, duty_cycle: float) → None[source]

Write a scaled analogue value to the PWM on a given GPIO pin.

Parameters:
  • identifier – pin number
  • duty_cycle – duty cycle to write
Raises:

NotImplementedError – Not implemented in any supported firmware yet.

class j5.backends.console.j5.arduino.PinData(*, mode: j5.components.gpio_pin.GPIOPinMode, digital_state: bool)[source]

Bases: object

Contains data about a pin.