ESE519-FinalProj “Wrangler”
Demonstration
The Completed Wrangler looks like:

Gif in action:
Joystick Mode:
Use the joystick located on the left hand side of the horse to control the direction of the Wrangler.

Sound Mode:
Make any sound would drive the Wrangler forward, at the same time, wave the whip and hit the horse once.

1. Problem 1: Servo motor
Problem: the starting, ending angle of servo motor are not precise. The rotation rate of servo motor is not stable. It frequently clogs when not placed horizontally.
Solution: implement an additional servo motor driver voltage level shifter breakout board that takes in a GPIO PWM and outputs a higher- voltage-protected PWM wave that feeds to the servo motor. With separate power supply and reworked PWM wave GPIO output, the behaviour is now stable.
PIO was used for the LED(mode indicator) and to drive the APDS9960 distance/motion sensor.
The general steps we programmed the PIO state machine are:
Determine which PIO instance to use(out of 2) PIO pio = pio0; PIO pio = pio1;
Assign instructions into instruction memory with sufficient space uint offset = pio_add_program(pio, &program_name_here)
Find an available state machine uint sm = pio_claim_unused_sm(pio, true); some_kind_of_program_init(pio, sm, offset, PICO_DEFAULT_LED_PIN);
Up to this point, state machine is ready and running.