#!/usr/bin/perl

$t=1;
$s=127;
$d= 32; # The size of the steps. 

for($x=0;$x<5;$x++){

  for($t=1;$t<128;$t+=$d){
    $s = $t + 127;
    $t_str = sprintf("echo -n -e \"\\%o\" > /dev/pwm0",$t);
    $s_str = sprintf("echo -n -e \"\\%o\" > /dev/pwm1",$s);
    system($t_str);  # drives pwm
    system($s_str);  # drives pwm
  }
 
  for($t=128;$t<256;$t+=$d){
    $s = 383 - $t;
    $t_str = sprintf("echo -n -e \"\\%o\" > /dev/pwm0",$t);
    $s_str = sprintf("echo -n -e \"\\%o\" > /dev/pwm1",$s);
    system($t_str);  # drives pwm
    system($s_str);  # drives pwm
  }
 
  for($t=255;$t>127;$t-=$d){
    $s = $t - 127;
    $t_str = sprintf("echo -n -e \"\\%o\" > /dev/pwm0",$t);
    $s_str = sprintf("echo -n -e \"\\%o\" > /dev/pwm1",$s);
    system($t_str);  # drives pwm
    system($s_str);  # drives pwm
  }
 
 for($t=127;$t>0;$t-=$d){
    $s = 127 - $t;
    $t_str = sprintf("echo -n -e \"\\%o\" > /dev/pwm0",$t);
    $s_str = sprintf("echo -n -e \"\\%o\" > /dev/pwm1",$s);
    system($t_str);  # drives pwm
    system($s_str);  # drives pwm
  }
}
