NLT

10, 20 en 30 seconden timer maken (adafruit circuit playground express)

Inleiding

In deze VLC Instructable zal ik je leren hoe je een timer kan maken met behulp van de website: https://makecode.adafruit.com/. We gaan een timer maken die af gaat na 10, 20 of 30 seconden afhankelijk van de invoer en die uitgaat als je de circuit playground express op zijn kop doet.

  • Een Adafruit circuit playground express
  • Een micro-usb kable die data kan overbrengen

Afbeelding afkomstig van de website: https://www.adafruit.com/product/3333

Werkplan

 
let Loop = 0
input.buttonA.onEvent(ButtonEvent.Click, function () {
light.showRing(
`black black black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black black purple`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black blue black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black red black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black orange black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black yellow black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black green black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black blue black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black purple black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black pink black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`white black black black black black black black black black`
)
pause(__internal.__timePicker(400))
Loop = 100
for(let i =0; i < Loop; i++){
music.playSound(music.sounds(Sounds.Siren))
light.showAnimation(light.theaterChaseAnimation, __internal.__timePicker(500))
}
})
input.buttonB.onEvent(ButtonEvent.Click, function () {
light.showRing(
`black black black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black black purple`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black blue black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black red black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black orange black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black yellow black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black green black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black blue black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black purple black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black pink black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`white black black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black black purple`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black blue black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black red black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black orange black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black yellow black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black green black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black blue black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black purple black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black pink black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`white black black black black black black black black black`
)
pause(__internal.__timePicker(400))
Loop = 100
for(let i =0; i < Loop; i++){
music.playSound(music.sounds(Sounds.Siren))
light.showAnimation(light.theaterChaseAnimation, __internal.__timePicker(500))
}
})
input.buttonsAB.onEvent(ButtonEvent.Click, function () {
light.showRing(
`black black black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black black purple`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black blue black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black red black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black orange black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black yellow black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black green black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black blue black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black purple black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black pink black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`white black black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black black purple`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black blue black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black red black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black orange black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black yellow black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black green black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black blue black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black purple black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black pink black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`white black black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black black purple`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black black blue black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black black red black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black black orange black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black black yellow black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black black green black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black black blue black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black black purple black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`black pink black black black black black black black black`
)
pause(__internal.__timePicker(500))
light.showRing(
`white black black black black black black black black black`
)
pause(__internal.__timePicker(400))
Loop = 100
for(let i =0; i < Loop; i++){
music.playSound(music.sounds(Sounds.Siren))
light.showAnimation(light.theaterChaseAnimation, __internal.__timePicker(500))
}
})
input.onGesture(Gesture.FaceDown, function () {
Loop = 0
light.showRing(
`black black black black black black black black black black`
)
})

 

– Plak de code in de editor bij de javascript tabblad
– Klik vervolgens op download in de editor, je krijgt een bestand die eindigt op .uf2
– Sluit je circuit playground express aan met een micro-usb
– Klik op de reset knopje, je ziet het board dan op je computer onder apparaten
– Sleep het .uf2 bestand naar het board en klaar ben je.
– Knop A = 10 seconden knop B = 20 seconden en A en B allebei ingedrukt = 30 seconden
– Om de timer uit te zetten doe je het board op zijn kop en dan stopt het.
 

 

 

Leave a Reply