ARC Pro

Upgrade to ARC Pro

Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.

PRO
Belgium
#57  

bobsheaux

do you have two pwm's in your project?

PRO
USA
#58  

Nomad, in the code above, make sure you initialize : on the top

$soundright = 0

or code  will not  work

EzAng

PRO
Belgium
#59  

hi ezang

i only changed the ports below.what means initialize ?

PRO
USA
#60   — Edited

Here is the correct code, I did change the sleep below so it would blink faster, also I am just using D0 so I # D1 out $pwmvalue = 0 $soundright = 0

code:

Sound servo to PWM range Script

Author: Rich

Version: 1.0.0

Date: 25th June 2013

modified by EzAng  August 2020

Variables (do not adjust)

$soundright = auto

$pwmvalue = 0 $soundright = 0

Sound servo to PWM range Script

Author: Rich

Version: 1.0.0

Date: 25th June 2013

Variables (do not adjust)

$soundright = auto

$pwmvalue = 0

Sound servo to PWM range Script

Author: Rich

Version: 1.0.0

Date: 25th June 2013

Variables (do not adjust)

$soundright = 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 ($soundright < 10) $pwmvalue = 0 ELSEIF ($soundright < 20) $pwmvalue = 10 ELSEIF ($soundright < 30) $pwmvalue = 20 ELSEIF ($soundright < 40) $pwmvalue = 30 ELSEIF ($soundright < 50) $pwmvalue = 40 ELSEIF ($soundright < 60) $pwmvalue = 50 ELSEIF ($soundright < 70) $pwmvalue = 60 ELSEIF ($soundright < 80) $pwmvalue = 70 ELSEIF ($soundright < 90) $pwmvalue = 80 ELSEIF ($soundright < 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(D1, $pwmvalue) PWM(D0, $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(1000)

#61  

You're saying "servo mic". What is "servo mic"? I see Sound servo (EZB), Sound servo (PC), Sound servo (EZB Playback), Sound servo (PC Mic), and Sound servo (PC Speaker), but I'm not seeing any "Servo Mic". I'm trying to get the LED to respond to the speech coming out of the EZB, so which of those do I use for that?  You said that for the LED, all that I need is the script and the servo mic control, but then you say that I need to have the Sound PC v4 paused?

And I can't run the script. It's just giving me this:

Line 1: Unexpected token ILLEGAL

Again, I PROMISE YOU, I'm not TRYING to be confused or argumentative here.:(

PRO
Belgium
#62  

ezang

my script for blink is this.

pwm(d0,100) pwm(d1,100) sleep(500) pwm(d1,0) sleep(500) pwm(d1,100)

PRO
USA
#64  

Bobsheaux it is sound servo (PC)

EzAng