Luuc
Published © GPL3+

Pulsed Grove - Blue LED

Which type of pulse are you? Push A-button to have an external LED pulsing 4 times smoothly or push B-button and it will pulse differently.

BeginnerFull instructions provided12 minutes1,200
Pulsed Grove - Blue LED

Things used in this project

Hardware components

Calliope mini v0.3 (pre-production)
Calliope mini v0.3 (pre-production)
×1
Seeed Studio grove blue LED
×1

Software apps and online services

Calliope mini pxt.calliope.cc

Story

Read more

Code

ExpoBlink

JavaScript
Actually compares square with linear LED pulses, press button A for a nice and smooth or press B to linearity change intensity.
let index = 0
input.onButtonPressed(Button.A, () => {
    for (let i = 0; i <= 4 - 1; i++) {
        while (index <= 31) {
            pins.analogWritePin(AnalogPin.C16, scores[index])
            index += 1
            basic.pause(20)
        }
        while (index >= 0) {
            pins.analogWritePin(AnalogPin.C16, scores[index])
            index += -1
            basic.pause(20)
        }
    }
})
input.onButtonPressed(Button.B, () => {
    for (let j = 0; j <= 4 - 1; j++) {
        while (index <= 31) {
            pins.analogWritePin(AnalogPin.C16, scores2[index])
            index += 1
            basic.pause(20)
        }
        while (index >= 0) {
            pins.analogWritePin(AnalogPin.C16, scores2[index])
            index += -1
            basic.pause(20)
        }
    }
})
let scores: number[] =[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 528, 575, 624, 675, 728, 783, 840, 899, 960, 1023, 1023];
let scores1: number[] =[0, 205, 324, 409, 475, 529, 574, 614, 649, 680, 708, 733, 757, 779, 799, 818, 836, 853, 869, 884, 899, 912, 926, 938, 950, 962, 973, 984, 994, 1004, 1014, 1023];
let scores2: number[] =[32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800, 832, 864, 896, 928, 960, 992, 1023, 1023];

Credits

Luuc

Luuc

8 projects • 3 followers
Thanks to Ulli Sommer.

Comments