Jeffrey Fox
Published

CPX Baseball-bat Golf Club

This is my home made golf club for golf with your friends. Made with a baseball bat and a Circuit playground express

AdvancedProtip1 hour380
CPX Baseball-bat Golf Club

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
×1

Software apps and online services

Golf with your Friends golf game

Story

Read more

Code

Untitled file

JavaScript
input.buttonA.onEvent(ButtonEvent.Up, function () {
    mouse.setButton(MouseButton.Left, false)
})
input.buttonA.onEvent(ButtonEvent.Down, function () {
    mouse.setButton(MouseButton.Left, true)
})
forever(function () {
    console.logValue("x", input.acceleration(Dimension.X))
    console.logValue("y", input.acceleration(Dimension.Y))
    if (input.acceleration(Dimension.Y) > 400) {
        mouse.move(0, 20)
    } else if (input.acceleration(Dimension.Y) < -400) {
        mouse.move(0, -20)
    } else if (input.acceleration(Dimension.X) > 400) {
        mouse.move(20, 0)
    } else if (input.acceleration(Dimension.X) < -400) {
        mouse.move(-20, 0)
    } else if (input.acceleration(Dimension.X) > 200 && input.acceleration(Dimension.Y) > 200) {
        mouse.move(20, 20)
    } else if (input.acceleration(Dimension.X) < -200 && input.acceleration(Dimension.Y) < -200) {
        mouse.move(-20, -20)
    } else if (input.acceleration(Dimension.X) > 200 && input.acceleration(Dimension.Y) < -200) {
        mouse.move(20, -20)
    } else if (input.acceleration(Dimension.X) < -200 && input.acceleration(Dimension.Y) > 200) {
        mouse.move(-20, 20)
    } else if (input.acceleration(Dimension.X) > 100 && input.acceleration(Dimension.Y) > 300) {
        mouse.move(20, 20)
    } else if (input.acceleration(Dimension.X) < -100 && input.acceleration(Dimension.Y) < -300) {
        mouse.move(-20, -20)
    } else if (input.acceleration(Dimension.X) > 300 && input.acceleration(Dimension.Y) > 100) {
        mouse.move(20, 20)
    } else if (input.acceleration(Dimension.X) < -300 && input.acceleration(Dimension.Y) < -100) {
        mouse.move(-20, -20)
    } else if (input.acceleration(Dimension.X) > 300 && input.acceleration(Dimension.Y) < -100) {
        mouse.move(20, -20)
    } else if (input.acceleration(Dimension.X) < -300 && input.acceleration(Dimension.Y) < 100) {
        mouse.move(-20, 20)
    } else if (input.acceleration(Dimension.X) > 100 && input.acceleration(Dimension.Y) < -300) {
        mouse.move(20, -20)
    } else if (input.acceleration(Dimension.X) < -100 && input.acceleration(Dimension.Y) > 300) {
        mouse.move(-20, 20)
    } else if (input.acceleration(Dimension.X) > 50 && input.acceleration(Dimension.Y) > 350) {
        mouse.move(20, 20)
    } else if (input.acceleration(Dimension.X) < -50 && input.acceleration(Dimension.Y) > -350) {
        mouse.move(-20, -20)
    } else if (input.acceleration(Dimension.X) > 150 && input.acceleration(Dimension.Y) > 250) {
        mouse.move(20, 20)
    } else if (input.acceleration(Dimension.X) < -150 && input.acceleration(Dimension.Y) < -250) {
        mouse.move(-20, -20)
    } else if (input.acceleration(Dimension.X) > 250 && input.acceleration(Dimension.Y) > 150) {
        mouse.move(20, 20)
    } else if (input.acceleration(Dimension.X) < -250 && input.acceleration(Dimension.Y) < -250) {
        mouse.move(-20, -20)
    } else if (input.acceleration(Dimension.X) > 350 && input.acceleration(Dimension.Y) > 50) {
        mouse.move(20, 20)
    } else if (input.acceleration(Dimension.X) < -350 && input.acceleration(Dimension.Y) > -50) {
        mouse.move(-20, -20)
    } else if (input.acceleration(Dimension.X) < 350 && input.acceleration(Dimension.Y) > 50) {
        mouse.move(-20, 20)
    } else if (input.acceleration(Dimension.X) > 350 && input.acceleration(Dimension.Y) > -50) {
        mouse.move(20, -20)
    } else if (input.acceleration(Dimension.X) < -250 && input.acceleration(Dimension.Y) > 150) {
        mouse.move(-20, 20)
    } else if (input.acceleration(Dimension.X) > 250 && input.acceleration(Dimension.Y) > -150) {
        mouse.move(20, -20)
    } else if (input.acceleration(Dimension.X) < -150 && input.acceleration(Dimension.Y) > 250) {
        mouse.move(-20, 20)
    } else if (input.acceleration(Dimension.X) > 150 && input.acceleration(Dimension.Y) < -250) {
        mouse.move(20, -20)
    } else if (input.acceleration(Dimension.X) < -50 && input.acceleration(Dimension.Y) > 350) {
        mouse.move(-20, 20)
    } else if (input.acceleration(Dimension.X) > 50 && input.acceleration(Dimension.Y) < -350) {
        mouse.move(20, -20)
    }
})

Credits

Jeffrey Fox

Jeffrey Fox

4 projects • 0 followers

Comments