Spine Straightener
The device will light red when the user's spine is not straight.
Supplies:
- CPX(Circuit Playground Express) with a battery pack
- 3 small batteries
- Non-conductive thread
- Needle
- Scissors(for cutting the needle)
Coding
Upload the following Code to the CPX either through block code or by copy pasting the javascript provided.
input.buttonA.onEvent(ButtonEvent.Click, function () {
if (mute == 1) {
mute = 0
} else {
mute = 1
}
})
let mute = 0
mute = 1
music.setVolume(255)
forever(function () {
if (input.acceleration(Dimension.Z) < 50) {
light.showRing(
`green green green green green green green green green green`
)
} else {
light.showRing(
`red red red red red red red red red red`
)
if (mute == 1) {
music.playTone(120, music.beat(BeatFraction.Breve))
}
}
})
The code will check for the incline of the Z-axis using the accelerometer on the CPX. If the value is too high, it lights red. By default, when it turns red, it continuously makes a sound, alerting the user. However this feature can be disabled by pressing the A button on the CPX.
Attach the CPX to the Battery Pack
Use non-conductive thread to attach the CPX to the battery pack. The thread can go through the pins on the CPX.
However, make sure that in the back all the thread doesn't go under the "belt" on the battery pack. Otherwise you won't be able to put it on a T-Shirt.
Try It Out
Attach the battery pack to your T-Shirt and turn on the switch on the battery pack.