What does this line of code do?

The Raspberry Pi is a series of credit card-sized single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools and developing countries.

Post Reply
User avatar
/RaspberryPi
Corporate
Posts: 2449
Joined: Wed Jun 05, 2019 1:29 am

What does this line of code do?

Post by /RaspberryPi »

I know that it runs an if statement that seems to never be satisfied, but im unsure how to go about starting the "timer 4 next run", etc.
I know it imports the USB aka raspberry pi, then imports keyboard and keycode to essentially do button presses/keystrokes?

Also, when running this open ended code, its impossible to turn it off and I essentially have to turn it off to get the code to stop running due to it supposed to being a bot for a game essentially.

import time import usb_hid import random from adafruit_hid.keyboard import Keyboard from adafruit_hid.keycode import Keycode keyboard = Keyboard(usb_hid.devices) TIMER_1_DELAY = 1 TIMER_4_DELAY = 250 now = time.monotonic() timer_1_next_run = now + TIMER_1_DELAY timer_4_next_run = now + 90 **a bunch of definitions go here** while True: now = time.monotonic() if now > timer_1_next_run: **CODE ENTERS HERE**
submitted by /u/ReasyxD
[link] [comments]

More...
Post Reply

Return to “Raspberry Pi Forum”