AnalogPin.P0 not supported

This commit is contained in:
Peli de Halleux 2016-11-10 13:08:45 -08:00
parent ce24e9d923
commit d6cc95112c
8 changed files with 20 additions and 20 deletions

View File

@ -5,23 +5,23 @@ Control currents in Pins for analog/digital signals, servos, i2c, ...
```cards ```cards
pins.digitalReadPin(DigitalPin.P0); pins.digitalReadPin(DigitalPin.P0);
pins.digitalWritePin(DigitalPin.P0, 0); pins.digitalWritePin(DigitalPin.P0, 0);
pins.analogReadPin(AnalogPin.P0); pins.analogReadPin(AnalogPin.P1);
pins.analogWritePin(AnalogPin.P0, 1023); pins.analogWritePin(AnalogPin.P1, 1023);
pins.analogSetPeriod(AnalogPin.P0, 20000); pins.analogSetPeriod(AnalogPin.P1, 20000);
pins.map(0, 0, 1023, 0, 4); pins.map(0, 0, 1023, 0, 4);
pins.onPulsed(DigitalPin.P0, PulseValue.High, () => { pins.onPulsed(DigitalPin.P0, PulseValue.High, () => {
}); });
pins.pulseDuration(); pins.pulseDuration();
pins.pulseIn(DigitalPin.P0, PulseValue.High); pins.pulseIn(DigitalPin.P0, PulseValue.High);
pins.servoWritePin(AnalogPin.P0, 180); pins.servoWritePin(AnalogPin.P1, 180);
pins.servoSetPulse(AnalogPin.P0, 1500); pins.servoSetPulse(AnalogPin.P1, 1500);
pins.i2cReadNumber(0, NumberFormat.Int8LE); pins.i2cReadNumber(0, NumberFormat.Int8LE);
pins.i2cWriteNumber(0, 0, NumberFormat.Int8LE); pins.i2cWriteNumber(0, 0, NumberFormat.Int8LE);
pins.spiWrite(0); pins.spiWrite(0);
pins.setPull(DigitalPin.P0, PinPullMode.PullDown); pins.setPull(DigitalPin.P0, PinPullMode.PullDown);
pins.analogPitch(0, 0); pins.analogPitch(0, 0);
pins.analogSetPitchPin(AnalogPin.P0); pins.analogSetPitchPin(AnalogPin.P1);
``` ```
### See Also ### See Also

View File

@ -4,7 +4,7 @@ Read an **analog** signal (`0` through `1023`) from the
[pin](/device/pins) you say. [pin](/device/pins) you say.
```sig ```sig
pins.analogReadPin(AnalogPin.P0) pins.analogReadPin(AnalogPin.P1)
``` ```
### Parameters ### Parameters

View File

@ -5,7 +5,7 @@ analog [pin](/device/pins).
Before you call this function, you should set the specified pin as analog. Before you call this function, you should set the specified pin as analog.
```sig ```sig
pins.analogSetPeriod(AnalogPin.P0, 20000) pins.analogSetPeriod(AnalogPin.P1, 20000)
``` ```
### Parameters ### Parameters
@ -17,8 +17,8 @@ The following code first sets `P0` to analog with **analog write
pin**, and then sets the PWM period of `P0` to 20,000 microseconds. pin**, and then sets the PWM period of `P0` to 20,000 microseconds.
```blocks ```blocks
pins.analogWritePin(AnalogPin.P0, 512) pins.analogWritePin(AnalogPin.P1, 512)
pins.analogSetPeriod(AnalogPin.P0, 20000) pins.analogSetPeriod(AnalogPin.P1, 20000)
``` ```
### See also ### See also

View File

@ -3,7 +3,7 @@
Specify which [pin](/device/pins) (P0, P1, P2) is used to generate tones. Specify which [pin](/device/pins) (P0, P1, P2) is used to generate tones.
```sig ```sig
pins.analogSetPitchPin(AnalogPin.P0) pins.analogSetPitchPin(AnalogPin.P1)
``` ```
### Parameters ### Parameters
@ -13,7 +13,7 @@ pins.analogSetPitchPin(AnalogPin.P0)
### Example ### Example
```blocks ```blocks
pins.analogSetPitchPin(AnalogPin.P0) pins.analogSetPitchPin(AnalogPin.P1)
let frequency = 440 let frequency = 440
let duration = 1000 let duration = 1000
pins.analogPitch(frequency, duration) pins.analogPitch(frequency, duration)

View File

@ -4,7 +4,7 @@ Write an **analog** signal (`0` through `1023`) to the
[pin](/device/pins) you say. [pin](/device/pins) you say.
```sig ```sig
pins.analogWritePin(AnalogPin.P0, 400) pins.analogWritePin(AnalogPin.P1, 400)
``` ```
### Parameters ### Parameters
@ -17,7 +17,7 @@ pins.analogWritePin(AnalogPin.P0, 400)
This program writes `1023` to pin `P0`. This program writes `1023` to pin `P0`.
```blocks ```blocks
pins.analogWritePin(AnalogPin.P0, 1023) pins.analogWritePin(AnalogPin.P1, 1023)
``` ```
#### ~hint #### ~hint

View File

@ -28,7 +28,7 @@ This example maps the value read from the analog pin `P0` to an LED
coordinate between `0` and `4`. coordinate between `0` and `4`.
```blocks ```blocks
let value1 = pins.analogReadPin(AnalogPin.P0) let value1 = pins.analogReadPin(AnalogPin.P1)
let index = pins.map(value1, 0, 1023, 0, 4) let index = pins.map(value1, 0, 1023, 0, 4)
led.plot(0, index) led.plot(0, index)
``` ```

View File

@ -17,7 +17,7 @@ pins.servoSetPulse(AnalogPin.P1, 1500)
The following code sets the servo pulse to `1000` microseconds. The following code sets the servo pulse to `1000` microseconds.
```blocks ```blocks
pins.servoSetPulse(AnalogPin.P0, 1000) pins.servoSetPulse(AnalogPin.P1, 1000)
``` ```
### See also ### See also

View File

@ -9,7 +9,7 @@ full speed in one direction, `180` specifies full speed in the other,
and approximately `90` specifies no movement.) and approximately `90` specifies no movement.)
```sig ```sig
pins.servoWritePin(AnalogPin.P0, 180) pins.servoWritePin(AnalogPin.P1, 180)
``` ```
### Parameters ### Parameters
@ -22,7 +22,7 @@ pins.servoWritePin(AnalogPin.P0, 180)
#### Setting the shaft angle to midpoint on a servo #### Setting the shaft angle to midpoint on a servo
```blocks ```blocks
pins.servoWritePin(AnalogPin.P0, 90) pins.servoWritePin(AnalogPin.P1, 90)
``` ```
#### Controlling the shaft by using the tilt information of the accelerometer #### Controlling the shaft by using the tilt information of the accelerometer
@ -32,14 +32,14 @@ basic.forever(() => {
let millig = input.acceleration(Dimension.X) let millig = input.acceleration(Dimension.X)
// map accelerometer readings to angle // map accelerometer readings to angle
let angle = pins.map(millig, -1023, 1023, 0, 180) let angle = pins.map(millig, -1023, 1023, 0, 180)
pins.servoWritePin(AnalogPin.P0, angle) pins.servoWritePin(AnalogPin.P1, angle)
}) })
``` ```
#### 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.P1, 0)
``` ```
### See also ### See also