Copy the sample code to a folder on the Raspberry Pi.
Open terminal, and then go to the folder you copied the sample.
Run the sample with the following command:
python3 Remote_Decoder.py
Sample Code
Remote_Decoder.py
#!/usr/bin/env python3#This sample demonstrates reading remote controller PWM channels from an RC receiver.#Install RC Driver HAT library with "pip3 install turta-rcdriverhat"from time import sleepfrom turta_rcdriverhat import Turta_RCDriver#Initializerc = Turta_RCDriver.RCDriver()try:#Activate fan at 50% speed rc.set_fan(50)whileTrue:#Option one: Read all PWM channels in one shot#Useful when you need all the reading wihtin a minimal time pwm_all = rc.read_pwms()#Print the readingsif pwm_all isnotNone:#Check if data is receivedprint("PWM St....: "+str(pwm_all[0]))print("PWM Th....: "+str(pwm_all[1]))print("PWM A3....: "+str(pwm_all[2]))print("PWM A4....: "+str(pwm_all[3]))#Waitsleep(1.0)#Option two: Read PWM inputs one by one#Useful when you need only one reading pwm_s = rc.read_pwm(Turta_RCDriver.PWM_IN.STEERING)#Print the readingif pwm_s isnotNone:#Check if data is receivedprint("PWM St....: "+str(pwm_s))#Waitprint("-----")sleep(1.0)#Exit on CTRL+CexceptKeyboardInterrupt:print('Bye.')
Result
When you run the sample, it prints PWM pulse lengths applied to the receiver port. The example output should be like this: