ARC Pro

Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

PRO
Synthiam
#1  

This would work... Maps the adc's input between 0 and 255 to servo degrees 1 to 180. It'll work on d0 and ADC0.


while (true) {

  // duplicate this line for other servos
  Servo.setPosition(d0, Utility.map(ADC.get(ADC0), 0, 255, 1, 180));

  sleep(100);
}

PRO
Belgium
#2  

hi dj

i wanna use two ez wheel servo's. looks like the script is for one servo?

PRO
Belgium
#3  

oops i can duplicate for more servo's.got it

thank you

PRO
Belgium
#4  

got error

Start

Error on line 1: Missing String Quotes or Invalid Expression at index 0: while ( ( Done (00:00:00.0094850)

PRO
Synthiam
#5  

That’s JavaScript I posted. I’ll never ever post ezscript

PRO
Belgium
#6  

this what i have .

while(0)(true)
while(1)(true)

{ // duplicate this line for other servos

Servo.setPosition(d0, Utility.map(ADC.get(ADC0), 0, 255, 1, 180));

Servo.setPosition(d1, Utility.map(ADC.get(ADC1), 0, 255, 1, 180));

sleep(100);

}

PRO
Synthiam
#7  

lol how did you get that from my example hehe. Here you go...

while(true) {

Servo.setPosition(d0, Utility.map(ADC.get(ADC0), 0, 255, 1, 180));


Servo.setPosition(d1, Utility.map(ADC.get(ADC1), 0, 255, 1, 180));


sleep(100);

}
PRO
Belgium
#8  

haha i was not far off.but it doesn move the ADC0 servo. it move head d0 and d1. i wanted to use ADC0 and ADC1 alone

PRO
Belgium
#9  

i forgot to tel i wanted to use continious servo's from ez robot on port v0 and v1

PRO
USA
#10  

Hi Nomad, how are you and how is your new robot?

EzAng

PRO
Belgium
#11  

hi ezang

waiting for parts.do you have any idea how adc ports work with continious rotation?

PRO
Belgium
#13  

oh does the adc only have 3 volts?

PRO
USA
#14   — Edited

did you read the link I put on?

https://synthiam.com/Community/Tutorials/Using-ADC-Analog-to-Digital-Ports-Commands-and-Controls-16283

Steve said: Step 1. About the ADC ports. There are 8 ADC Ports on the EZ-B v4 numbered "A0" to "A7" that you can connect devices like analog sensors. Each ADC port contains three pins...

Ground: (output) located towards the centre of the board.

VDC: (output) The centre pin, regulated at 3.3 volts.

Signal: (input) The outermost pin from the centre of the board which reads the voltage between 0 and 3.3 volts.

The ADC ports are Configurable at 8-bit (0-255) or 12-bit (0-4095) in software.

In an ADC control found in the ARC software, such as "Read ADC", ADC reading intervals can be selected from 100 ms to 60000 millisecond analog values.

Analog readings are from 1 to 255 (0v to 3.3v) in 8 bit mode, or 0 to 4,095 in 12 bit mode.

read on

I have to leave now  - maybe Ptp or DJ can help, sorry

PRO
Belgium
#15  

ezang

yes i have the link

thanks

PRO
Belgium
#16  

Ezang

you cant controle a servo with adc ports.

thanks

PRO
Belgium
#18  

i saw it but you cant controle a servo on a adc port itself. i wonder would a LED work? on a adc port?

PRO
USA
#20  

Seems like you need a script:

Rich:

ADC to servo movement

:loop $value=GetADC(ADC0) $position = $value/100 $position = Round($position,0) Servo(D1,$position) Sleep(250) Goto(loop)

Or

/ ADC to servo movement

:loop $value=GetADC(ADC0) $position = $value/100 $position = Round($position,0) $position = Map($value, 54, 129, 180, 1 ) #adjusted first two values to read min/max read ADC project, 2nd two for direction (reverse 1 and 180). Servo(D0,$position) Sleep(250) Goto(loop)

PRO
Belgium
#21  

i wanted to use contineous rotation servo's.

PRO
USA
#22  

from NallyCat - @Nomad 6R there is a tutorial on synthiam for that, have a look at " Using ADC (Analog to Digital) Ports, Commands and Controls." by Steve G.

Looks like the one I already gave you - check

EzAng

PRO
Belgium
#23  

i have another question about adc ports.didn want to open another topic. is it possible to control a LED ,excample on/off ,with an adc port? i notest a led goes on from 3 volt.