Edited advanced topic.
This commit is contained in:
parent
055704b3ef
commit
835a4b5cf0
@ -1,9 +1,12 @@
|
|||||||
# Servo Write Pin
|
# Servo Write Pin
|
||||||
|
|
||||||
Writes a value to the servo on to the specified [pin](/device/pins) (``P0``, ``P1``, ``P2``), controlling the shaft accordingly.
|
Write a value to the servo on the specified [pin](/device/pins)
|
||||||
|
and control the shaft.
|
||||||
|
|
||||||
* on a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation.
|
This function will move the shaft of a standard servo to the specified
|
||||||
* on a continuous rotation servo, this will set the speed of the servo (with 0 being full-speed in one direction, 180 being full speed in the other, and a value near 90 being no movement).
|
angle, or set the speed of a continuous rotation servo. (`0` specifies
|
||||||
|
full speed in one direction, `180` specifies full speed in the other,
|
||||||
|
and approximately `90` specifies no movement.)
|
||||||
|
|
||||||
```sig
|
```sig
|
||||||
pins.servoWritePin(AnalogPin.P0, 180)
|
pins.servoWritePin(AnalogPin.P0, 180)
|
||||||
@ -11,18 +14,18 @@ pins.servoWritePin(AnalogPin.P0, 180)
|
|||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
* `name` - [String](/reference/types/string); the pin name ("P0", "P1", or "P2")
|
* a [string](/reference/types/string) that specifies the pin name (`P0` through `P4`, or `P10`)
|
||||||
* `value` - a [Number](/reference/types/number) between 0 and 180 included
|
* a [number](/reference/types/number) from `0` through `180`
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
* setting the shaft angle to mid point on a servo
|
#### Setting the shaft angle to midpoint on a servo
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
pins.servoWritePin(AnalogPin.P0, 90)
|
pins.servoWritePin(AnalogPin.P0, 90)
|
||||||
```
|
```
|
||||||
|
|
||||||
* control the shaft by using the tilt information of the accelerometer
|
#### Controlling the shaft by using the tilt information of the accelerometer
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.forever(() => {
|
basic.forever(() => {
|
||||||
@ -33,7 +36,7 @@ basic.forever(() => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
* setting the full speed on a continuous servo
|
#### Setting the full speed on a continuous servo
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
pins.servoWritePin(AnalogPin.P0, 0)
|
pins.servoWritePin(AnalogPin.P0, 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user