Luuc
Published © GPL3+

Sinusblinker

vierfarbig

BeginnerFull instructions provided12 minutes44

Things used in this project

Hardware components

Calliope mini
Calliope mini
×1

Story

Read more

Code

Sinusblinker-4farbig

JavaScript
let Sin: number[] = []
let geduld = 0
let farbe = 0
let Index = 0
input.onButtonPressed(Button.A, () => {
    farbe += 1
    if (farbe > 4) {
        farbe = 1
    }
})
farbe = 1
geduld = 40
Sin = [0, 0, 1, 3, 5, 8, 11, 15, 19, 23, 28, 34, 39, 45, 51, 58, 64, 70, 76, 83, 88, 94, 100, 105, 109, 113, 117, 120, 123, 125, 127, 128, 128]
basic.forever(() => {
    while (farbe == 1) {
        for (let Index = 0; Index <= 31; Index++) {
            basic.setLedColor(basic.rgbw(
            Sin[Index],
            0,
            0,
            0
            ))
            Index += 1
            basic.pause(geduld)
        }
        Index = 0
        for (let Index = 0; Index <= 31; Index++) {
            basic.setLedColor(basic.rgbw(
            Sin[31 - Index],
            0,
            0,
            0
            ))
            Index += 1
            basic.pause(geduld)
        }
        Index = 0
    }
    while (farbe == 2) {
        for (let Index = 0; Index <= 31; Index++) {
            basic.setLedColor(basic.rgbw(
            0,
            Sin[Index],
            0,
            0
            ))
            Index += 1
            basic.pause(geduld)
        }
        Index = 0
        for (let Index = 0; Index <= 31; Index++) {
            basic.setLedColor(basic.rgbw(
            0,
            Sin[31 - Index],
            0,
            0
            ))
            Index += 1
            basic.pause(geduld)
        }
        Index = 0
    }
    while (farbe == 3) {
        for (let Index = 0; Index <= 31; Index++) {
            basic.setLedColor(basic.rgbw(
            0,
            0,
            Sin[Index],
            0
            ))
            Index += 1
            basic.pause(geduld)
        }
        Index = 0
        for (let Index = 0; Index <= 31; Index++) {
            basic.setLedColor(basic.rgbw(
            0,
            0,
            Sin[31 - Index],
            0
            ))
            Index += 1
            basic.pause(geduld)
        }
        Index = 0
    }
    while (farbe > 3) {
        for (let Index = 0; Index <= 31; Index++) {
            basic.setLedColor(basic.rgbw(
            Sin[Index],
            Sin[Index],
            Sin[Index],
            0
            ))
            Index += 1
            basic.pause(geduld)
        }
        Index = 0
        for (let Index = 0; Index <= 31; Index++) {
            basic.setLedColor(basic.rgbw(
            Sin[31 - Index],
            Sin[31 - Index],
            Sin[31 - Index],
            0
            ))
            Index += 1
            basic.pause(geduld)
        }
        Index = 0
    }
})

Credits

Luuc
8 projects • 3 followers
Contact

Comments

Please log in or sign up to comment.