Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
David Linaburg
Published

Rocket Ship Controller

This is a game controller made in the shape of a rocket ship using an ultrasonic sensor and a CPX.

BeginnerShowcase (no instructions)150
Rocket Ship Controller

Story

Read more

Code

Strange Controller Code

JavaScript
let distance = 0
input.onGesture(Gesture.Shake, function () {
    keyboard.type("q")
})
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
    light.graph(distance, 50)
    if (distance >= 16 && distance <= 100) {
        keyboard.type("w")
    } else if (distance <= 8 && distance >= 0) {
        keyboard.type("s")
    }
    console.logValue("distancecm", distance)
})

Credits

David Linaburg
4 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.