#!/bin/bash
set -x
#Export PWM channel for user control.
sudo sh -c "echo 0 > /sys/class/pwm/pwmchip0/export"
#Select the period of PWM signal. Value is in nanoseconds.
sudo sh -c "echo 20000000 >
/sys/class/pwm/pwmchip0/pwm0/period"
#Change the polarity of the PWM signal.
#The polarity can only be changed if the PWM is not
enabled.
sudo sh -c "echo "normal" >
/sys/class/pwm/pwmchip0/pwm0/polarity"
#Enable the PWM signal.
sudo sh -c "echo 1 >
/sys/class/pwm/pwmchip0/pwm0/enable"
#Select the duty cycle. Value is in nanoseconds and must
be less than the period.
#Move to Center
sudo sh -c "echo 1450000 >
/sys/class/pwm/pwmchip0/pwm0/duty_cycle"
sleep 2
#Move to Angle +90
sudo sh -c "echo 2350000 >
/sys/class/pwm/pwmchip0/pwm0/duty_cycle"
sleep 2
#Move to Angle -90
sudo sh -c "echo 625000 >
/sys/class/pwm/pwmchip0/pwm0/duty_cycle"
sleep 2
#Move to Center
sudo sh -c "echo 1450000 >
/sys/class/pwm/pwmchip0/pwm0/duty_cycle"
sleep 2
#Disable the PWM signal.
sudo sh -c "echo 0 >
/sys/class/pwm/pwmchip0/pwm0/enable"
#UnExport PWM channel for user control.
sudo sh -c "echo 0 > /sys/class/pwm/pwmchip0/unexport"
|