In this video lesson we will become familiar with the FUSION AI HAT+, and we will learn how to do digital inputs and outputs, analog in readings, analog outputs, PWM and how to control servos. By the end of the lesson you should have the essentials you need to work with the Fusion HAT+. The schematic for the circuit we will be using in today’s lesson if below. We describe it in more detail in the video. The schematic is:

In the video lesson we demonstrated the following programs:
Digital output to blink an LED:
1 2 3 4 5 6 7 8 9 10 | from fusion_hat.pin import Pin, Mode import time LEDPin=17 redLED = Pin(LEDPin,mode=Mode.OUT) while True: redLED.high() time.sleep(.1) redLED.low() time.sleep(.1) |
PWM Example to Control RGB LED Color and Brightness.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | from fusion_hat.pwm import PWM from time import sleep redPin = 5 greenPin = 6 bluePin = 7 redLED = PWM(redPin) greenLED=PWM(greenPin) blueLED=PWM(bluePin) redLED.freq(200) greenLED.freq(200) blueLED.freq(200) while True: for bright in range(0, 101, 1): redLED.pulse_width_percent(bright) sleep(0.01) print(bright) for bright in range(99, 0, -1): redLED.pulse_width_percent(bright) sleep(0.01) print(bright) |
Reading Analog Voltages on the Pi 5 Using the Fusion HAT+
1 2 3 4 5 6 7 8 9 10 11 | from fusion_hat.adc import ADC from time import sleep potPin=0 myPot = ADC(potPin) # A0–A3 on HAT while True: analogIn = myPot.read() voltage=analogIn*(3.3/4095) print("Analog In: ",analogIn,"Voltage: ",round(voltage,2)) sleep(0.1) |
Controlling Servos With the Fusion AI HAT+
1 2 3 4 5 6 7 8 9 | from fusion_hat.servo import Servo # Import the Servo class for controlling servos import time # Import sleep for timing delays panPin=2 tiltPin=3 servoPan = Servo(panPin) servoTilt=Servo(tiltPin) servoPan.angle(0) servoTilt.angle(0) |
