20 min-project of today: creepy squirrel
Written by marcelpetrick on December 1, 2017
Had in mind to play around with the “make LED shine directly via PIN”-feature of the Calliope Mini. Worked, nice 🙂
Actually for both “eyes” it is randomnly picked if they shall light up (and down) separately, but the GIF can can last just 3 seconds.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
let ledpowerinverted = 0 let pin2 = false let pin1 = false basic.forever(() => { pin1 = Math.randomBoolean() pin2 = Math.randomBoolean() for (let ledpower = 0; ledpower <= 1023; ledpower++) { if (pin1) { pins.analogWritePin(AnalogPin.P1, ledpower) } if (pin2) { pins.analogWritePin(AnalogPin.P2, ledpower) } basic.pause(2) } for (let ledpower2 = 0; ledpower2 <= 1023; ledpower2++) { ledpowerinverted = 1023 - ledpower2 if (pin1) { pins.analogWritePin(AnalogPin.P1, ledpowerinverted) } if (pin2) { pins.analogWritePin(AnalogPin.P2, ledpowerinverted) } basic.pause(2) } basic.pause(500) }) |