Asked
Resolved Resolved by EzAng!

Using ADC Ports

is there a possebility to use the ADC inputs for controlling a servo? i try the micro servo a,d a HDD from ez robot. that didn work.



Related Hardware (view all EZB hardware)
EZ-B Iotiny by EZ-Robot
Control IoTiny with Synthiam ARC: 100MHz Cortex‑M4 Wi‑Fi IoT/robot controller-camera, servos, ADC, I2C and digital I/O for easy internet automation
Wi-Fi / USB
Servos 8
Camera
Audio
UART
I2C
ADC
Digital

ARC Pro

Upgrade to ARC Pro

ARC Pro is your gateway to a community of like-minded robot enthusiasts and professionals, all united by a passion for advanced robot programming.

Author Avatar
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);
}
Author Avatar
PRO
Belgium
#2  

hi dj

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

Author Avatar
PRO
Belgium
#3  

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

thank you

Author Avatar
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)

Author Avatar
PRO
Synthiam
#5  

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

Author Avatar
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);

}

Author Avatar
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);

}
Author Avatar
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