Caitlin DuncanAlyssa Blanco
Published © GPL3+

FX Machine

Control all three CPX as they communicate to each other.

BeginnerFull instructions provided1 hour109
FX Machine

Story

Read more

Code

CPX #1

JavaScript
input.buttonA.onEvent(ButtonEvent.Click, function () {
    network.infraredSendNumber(3)
    light.showRing(
    `pink white pink white pink white pink white pink white`
    )
})
network.onInfraredReceivedNumber(function (num) {
    if (num == 0) {
        light.showRing(
        `yellow green pink purple yellow green pink purple yellow green`
        )
    } else if (num == 1) {
        light.showAnimation(light.sparkleAnimation, 2000)
    } else if (num == 2) {
        music.playSoundUntilDone(music.sounds(Sounds.MagicWand))
    } else if (num == 3) {
        light.showRing(
        `pink white pink white pink white pink white pink white`
        )
    } else if (num == 4) {
        light.showAnimation(light.cometAnimation, 2000)
    } else if (num == 5) {
        music.playSoundUntilDone(music.sounds(Sounds.PowerUp))
    } else if (num == 6) {
        light.showRing(
        `blue purple blue purple blue red white red white red`
        )
    } else if (num == 7) {
        light.showAnimation(light.theaterChaseAnimation, 2000)
    } else if (num == 8) {
        music.playSoundUntilDone(music.sounds(Sounds.Wawawawaa))
    }
})
input.buttonB.onEvent(ButtonEvent.Click, function () {
    network.infraredSendNumber(4)
    light.showAnimation(light.cometAnimation, 2000)
})
forever(function () {
    while (input.lightLevel() == 10) {
        network.infraredSendNumber(5)
        music.playSoundUntilDone(music.sounds(Sounds.PowerUp))
    }
})

CPX #2

JavaScript
input.buttonA.onEvent(ButtonEvent.Click, function () {
    network.infraredSendNumber(6)
    light.showRing(
    `blue white blue white blue red white red white red`
    )
})
network.onInfraredReceivedNumber(function (num) {
    if (num == 0) {
        light.showRing(
        `yellow green pink purple yellow green pink purple yellow green`
        )
    } else if (num == 1) {
        light.showAnimation(light.sparkleAnimation, 2000)
    } else if (num == 2) {
        music.playSoundUntilDone(music.sounds(Sounds.MagicWand))
    } else if (num == 3) {
        light.showRing(
        `pink white pink white pink white pink white pink white`
        )
    } else if (num == 4) {
        light.showAnimation(light.cometAnimation, 2000)
    } else if (num == 5) {
        music.playSoundUntilDone(music.sounds(Sounds.PowerUp))
    } else if (num == 6) {
        light.showRing(
        `blue purple blue purple blue red white red white red`
        )
    } else if (num == 7) {
        light.showAnimation(light.theaterChaseAnimation, 2000)
    } else if (num == 8) {
        music.playSoundUntilDone(music.sounds(Sounds.Wawawawaa))
    }
})
input.buttonB.onEvent(ButtonEvent.Click, function () {
    network.infraredSendNumber(7)
    light.showAnimation(light.theaterChaseAnimation, 500)
})
forever(function () {
    while (input.lightLevel() == 20) {
        network.infraredSendNumber(8)
        music.playSoundUntilDone(music.sounds(Sounds.Wawawawaa))
    }
})

CPX #3

JavaScript
input.buttonA.onEvent(ButtonEvent.Click, function () {
    network.infraredSendNumber(0)
    light.showRing(
    `yellow green pink purple yellow green pink purple yellow green`
    )
})
network.onInfraredReceivedNumber(function (num) {
    if (num == 0) {
        light.showRing(
        `yellow green pink purple yellow green pink purple yellow green`
        )
    } else if (num == 1) {
        light.showAnimation(light.sparkleAnimation, 2000)
    } else if (num == 2) {
        music.playSoundUntilDone(music.sounds(Sounds.MagicWand))
    } else if (num == 3) {
        light.showRing(
        `pink white pink white pink white pink white pink white`
        )
    } else if (num == 4) {
        light.showAnimation(light.cometAnimation, 2000)
    } else if (num == 5) {
        music.playSoundUntilDone(music.sounds(Sounds.PowerUp))
    } else if (num == 6) {
        light.showRing(
        `blue purple blue purple blue red white red white red`
        )
    } else if (num == 7) {
        light.showAnimation(light.theaterChaseAnimation, 2000)
    } else if (num == 8) {
        music.playSoundUntilDone(music.sounds(Sounds.Wawawawaa))
    }
})
input.buttonB.onEvent(ButtonEvent.Click, function () {
    network.infraredSendNumber(1)
    light.showAnimation(light.sparkleAnimation, 500)
})
forever(function () {
    while (input.lightLevel() == 20) {
        network.infraredSendNumber(2)
        music.playSoundUntilDone(music.sounds(Sounds.MagicWand))
    }
})

Credits

Caitlin Duncan
4 projects • 0 followers
Alyssa Blanco
4 projects • 0 followers

Comments