androidthings / sample-simplepio

Basic Peripheral I/O examples with Android Things
Apache License 2.0
190 stars 79 forks source link

how to control more than 2 servos? #9

Open Mao-x-w opened 6 years ago

Mao-x-w commented 6 years ago

how to control more than 2 servos?because there were only two pwm(pwm0 and pwm1)

Fleker commented 6 years ago

If you require additional peripherals, you can find a peripheral to expand the number of available PWM outputs. Additionally, you could interface with a motor driver, which specifically is meant to drive a set of motors.

Mao-x-w commented 6 years ago

Can we use the GPIO port to simulate PWM output in Android Things.Like this:

void servo_pulse(int myangle) { int PulseWidth; PulseWidth = (myangle * 11) + 500; digitalWrite(ServoPin, HIGH); delayMicroseconds(PulseWidth); digitalWrite(ServoPin, LOW); delay(20 - PulseWidth / 1000); return; } I can't make the thread to sleep 0.5ms in Android Things.

Fleker commented 6 years ago

The GPIO control in Android Things doesn't have the level of precision that you may want for high frequency PWM.