Dominic Lincourt
Created November 6, 2020

Sensory Intervention with Colors and Sounds

Project 3: Sensory Intervention

Intermediate3 hours9
Sensory Intervention with Colors and Sounds

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
×1
Alligator Clips
Alligator Clips
×4
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×1
Harness Board Nails, Nickel Plated Steel
Harness Board Nails, Nickel Plated Steel
×4

Story

Read more

Schematics

Wiring Schematic

Code

SensoryInterventionV2.js

JavaScript
input.touchA4.onEvent(ButtonEvent.Click, function () {
    music.playTone(262, music.beat(BeatFraction.Half))
    red_value += 51
    red_note += 1
    light.setPixelColor(1, 0xffffff)
    pause(100)
    light.setPixelColor(1, 0xff0000)
    light.setPixelColor(6, light.rgb(red_value, green_value, blue_value))
})
input.touchA2.onEvent(ButtonEvent.Click, function () {
    music.playTone(587, music.beat(BeatFraction.Half))
    blue_value += 51
    blue_note += 1
    light.setPixelColor(8, 0xffffff)
    pause(100)
    light.setPixelColor(8, 0x0000ff)
    light.setPixelColor(6, light.rgb(red_value, green_value, blue_value))
})
input.touchA1.onEvent(ButtonEvent.Click, function () {
    light.setAll(light.rgb(red_value, green_value, blue_value))
    for (let i = 0; i < red_note; i++) {
        music.playTone(262, music.beat(BeatFraction.Half))
        music.rest(music.beat(BeatFraction.Half))
    }
    for (let i = 0; i < green_note; i++) {
        music.playTone(392, music.beat(BeatFraction.Half))
        music.rest(music.beat(BeatFraction.Half))
    }
    for (let i = 0; i < blue_note; i++) {
        music.playTone(587, music.beat(BeatFraction.Half))
        music.rest(music.beat(BeatFraction.Half))
    }
    pause(500)
    red_value = 0
    green_value = 0
    blue_value = 0
    green_note = 0
    blue_note = 0
    red_note = 0
    light.showRing(
        `black red black green black black black black blue black`
    )
})
input.touchA6.onEvent(ButtonEvent.Click, function () {
    music.playTone(392, music.beat(BeatFraction.Half))
    green_value += 51
    green_note += 1
    light.setPixelColor(3, 0xffffff)
    pause(100)
    light.setPixelColor(3, 0x00ff00)
    light.setPixelColor(6, light.rgb(red_value, green_value, blue_value))
})
let green_note = 0
let red_note = 0
let blue_note = 0
let blue_value = 0
let green_value = 0
let red_value = 0
music.setVolume(255)
light.showRing(
    `black red black green black black black black blue black`
)
red_value = 0
green_value = 0
blue_value = 0
blue_note = 0
red_note = 0
green_note = 0

circuitplayground-Sensory InterventionV2.uf2

JavaScript
No preview (download only).

Credits

Dominic Lincourt
4 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.