PololuAStar32u4 (pololu_a_star_32u4 v0.1.0)
View SourcePublic interface for controlling the Pololu A-Star 32U4 board when operating in RPi slave mode.
This library provides an Elixir interface for communicating with the Pololu A-Star 32U4 board via I2C. It allows controlling LEDs, motors, reading sensors and buttons, and playing melodies when the board is in RPi slave mode.
Summary
Functions
Plays a melody.
Reads the analog values from all channels.
Reads the battery voltage in millivolts.
Reads the state of the buttons.
Reads the motor encoder values.
Controls the state of the LEDs.
Controls the speed of the motors.
Functions
Plays a melody.
Parameters
song: String containing the notes to play
Examples
iex> PololuAStar32u4.play_song("c4e4g4c5")
:ok
Reads the analog values from all channels.
Returns
Returns a list of 6 analog values (0-1023).
Examples
iex> PololuAStar32u4.read_analog()
[512, 0, 1023, 256, 768, 100]
Reads the battery voltage in millivolts.
Examples
iex> PololuAStar32u4.read_battery_mv()
11700
Reads the state of the buttons.
Returns
Returns a map with the state of buttons A, B and C.
Examples
iex> PololuAStar32u4.read_buttons()
%{a: false, b: true, c: false}
Reads the motor encoder values.
Returns
Returns a tuple {left_encoder, right_encoder}.
Examples
iex> PololuAStar32u4.read_encoders()
{1250, -800}
Controls the state of the LEDs.
Parameters
yellow: State of the yellow LED (true/false)green: State of the green LED (true/false)red: State of the red LED (true/false)
Examples
iex> PololuAStar32u4.set_leds(yellow: true, green: false, red: true)
:ok
Controls the speed of the motors.
Parameters
left: Speed of the left motor (-400 to 400)right: Speed of the right motor (-400 to 400)
Examples
iex> PololuAStar32u4.set_motors(left: 200, right: -100)
:ok