analog Write
Write a value of between 0 and 255 to make a signal at an analog pin.
pins.analogWrite(AnalogPin.A0, 255)
An analog output at a pin will have an amount of voltage related to the output value
you give to ||pins:analog write||. You are setting the amount of signal at the pin.
You use values between 0 (for no signal) and 255 (for full signal). The actual voltage
on the pin will follow the value you give for the output. So, 0 is no voltage and 255
is maximun voltage. The voltage that matches your signal value depends on the
voltage range used by your board.
Parameters
- value: a number between
0(no signal) and255(full signal)
Example
Create a sawtooth wave signal on pin A0.
let i = 0
loops.forever(function() {
i = 0
while (i <= 255) {
pins.analogWrite(AnalogPin.A0, i)
loops.pause(100)
if (i > 0) {
i += 128
} else {
i += 127
}
}
})