Giovanni Minus
Published

Project 4: Strange Controller- Giovanni Minus

Using a pan to do simple button inputs in a game.

BeginnerShowcase (no instructions)1 hour327
Project 4: Strange Controller- Giovanni Minus

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
×1
Alligator Clips
Alligator Clips
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1

Software apps and online services

MakeCode
Microsoft MakeCode

Hand tools and fabrication machines

Tape, Clear
Tape, Clear

Story

Read more

Schematics

Pan Controller Demonstration

Pan Controller Construction 1

Pan Controller Construction 2

Pan Controller Construction 3

Pan Controller Construction 4

Code

MakeCode Block Code

JavaScript
let distance = 0
loops.forever(function () {
    pins.A2.digitalWrite(false)
    control.waitMicros(2)
    pins.A2.digitalWrite(true)
    control.waitMicros(10)
    pins.A2.digitalWrite(false)
    distance = pins.A1.pulseIn(PulseValue.High) / 58
    if (distance > 3 && distance <= 15) {
        light.setAll(0xffff00)
        keyboard.type("x")
    }
    if (distance >= 0.25 && distance <= 3) {
        light.setAll(0x007fff)
        keyboard.type("z")
    }
})

Credits

Giovanni Minus
3 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.