dbeard
I followed the tutorial to make the LED flash when my robot speaks. I noticed that if I have it set to the PC Speaker, the LED flashes in sync with the speaking but if I switch to the EzB, the flashing is not in sync and ends way before the talking completes. I am using the code from the tutorial (see below).
Sound servo to PWM range Script
Author: Rich
Version: 1.0.0
Date: 25th June 2013
Variables (do not adjust)
$soundvalue = auto
$pwmvalue = 0
Main script
Set the start point for the never ending loop
:loop
Check the variable from the Sound servo control against a list of pre-determined levels (you may need to change these) and set the PWM value to suit.
IF ($soundvalue < 10) $pwmvalue = 0 ELSEIF ($soundvalue < 20) $pwmvalue = 10 ELSEIF ($soundvalue < 30) $pwmvalue = 20 ELSEIF ($soundvalue < 40) $pwmvalue = 30 ELSEIF ($soundvalue < 50) $pwmvalue = 40 ELSEIF ($soundvalue < 60) $pwmvalue = 50 ELSEIF ($soundvalue < 70) $pwmvalue = 60 ELSEIF ($soundvalue < 80) $pwmvalue = 70 ELSEIF ($soundvalue < 90) $pwmvalue = 80 ELSEIF ($soundvalue < 100) $pwmvalue = 90 ELSE $pwmvalue = 100 ENDIF
Set the PWM with the value chosen above (you may need to change the port to suit)
PWM(D7, $pwmvalue)
Add any other PWM ports above this line with PWM(PortNo, $pwmvalue)
Sleep for 100ms to avoid saturation (you may need to adjust this to increase accuracy or increase stability. Reduce the delay for better accuracy, increase for better stability)
Sleep(100)
Jump back to the start
Goto(loop)
Any suggestions to make the EzB perform like the PC Speaker will be greatly appreciated.