Digital Write Pin

Write a digital (0 or 1) signal to a pin on the Calliope mini board.

pins.digitalWritePin(DigitalPin.P1, 1)

Some pins are also used by the LED screen. Please read the page about pins carefully.

Parameters

Example: football score keeper

This program reads pin P0 to find when a goal is scored. When P0 is 1, the program makes the score bigger and plays a buzzer sound through P2 with digital write pin.

let score = 0
basic.showNumber(score)
basic.forever(() => {
    if (pins.digitalReadPin(DigitalPin.P0) == 1) {
        score++;
        pins.digitalWritePin(DigitalPin.P2, 1)
        basic.showNumber(score)
        basic.pause(1000)
        pins.digitalWritePin(DigitalPin.P2, 0)
    }
})

This program is a remote control for the score keeper program. If you connect P1 on the remote control Calliope mini to P0 on the score keeper Calliope mini, you can press button B on the remote. This program will use digital write pin to make the other Calliope mini buzz and make the score bigger.

input.onButtonPressed(Button.B, () => {
    pins.digitalWritePin(DigitalPin.P1, 1);
    basic.pause(500);
    pins.digitalWritePin(DigitalPin.P1, 0);
});

See also

Calliope mini pins, digital read pin, analog read pin, analog write pin, on pin pressed

Edit this page on GitHub