Last active
March 1, 2025 04:02
-
-
Save Dygear/8b778f7199023f22daf1720d53b94f0c to your computer and use it in GitHub Desktop.
Auto Clicker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.adafruit.com/product/5302 | |
# https://circuitpython.org/board/adafruit_kb2040/ | |
# From https://circuitpython.org/libraries | |
# Need the adafruit_hid folder & neopixel.mpy file in the lib directory. | |
import time | |
import board | |
import usb_hid | |
import neopixel | |
from digitalio import DigitalInOut, Direction, Pull | |
from adafruit_hid.mouse import Mouse | |
RED = (255, 0, 0) | |
GRN = ( 0,255, 0) | |
BLU = ( 0, 0,255) | |
OFF = ( 0, 0, 0) | |
led = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.1, auto_write=False) | |
led.fill(BLU) | |
led.show() | |
btn = DigitalInOut(board.BUTTON) | |
btn.direction = Direction.INPUT | |
btn.pull = Pull.UP | |
btn_state = btn.value | |
m = Mouse(usb_hid.devices) | |
run = False | |
while True: | |
cur_state = btn.value | |
if cur_state != btn_state: | |
if not cur_state: | |
run = not run | |
print("BTN is down") | |
else: | |
print("BTN is up") | |
btn_state = cur_state | |
if run: | |
m.press(Mouse.LEFT_BUTTON) | |
led.fill(RED) | |
led.show() | |
time.sleep(0.125) | |
m.release(Mouse.LEFT_BUTTON) | |
led.fill(OFF) | |
led.show() | |
time.sleep(0.125) | |
else: | |
led.fill(GRN) | |
led.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment