One thing I do too much is watch YouTube videos. While doing so recently, I came across someone jesting at the idea of a device that only lets you watch videos for as long as you’re cranking the handle of a device.
I found this idea to be funny and novel, and quite possible for me to make in a few hours. So 2 hours later I had this rapid prototype:


The device uses a small DC motor with a prebuilt gearbox connected to a Makey Makey (an Atmega32U4 based microcontroller board) which can send keyboard inputs through a USB connection. When the crude handle on the box is spun, it uses the motor as a small generator to produce a current that is sent to the microcontroller. Because the microcontroller uses the grounding of pins to trigger, when we spin a motor connected to the “A” pin and GND pin it stops the pin from being grounded. The micro controller then sends the signal to the computer via USB telling it that the “A” key is being released. Yes, this means while you’re not spinning the motor, the computer thinks you’re holding down the “A” key.
The Programming
For as long as the motor is spun, the “A” key is not read as being pressed, however that by itself doesn’t start and stop a YouTube video. For that I needed to write a Python script.
import pynput
from pynput import keyboard
from pynput.keyboard import Controller, Key
import sys
keyboard_controller = Controller()
a_pressed = False
def on_press(key):
global a_pressed
try:
if key.char == 'a' and not a_pressed:
a_pressed = True
print("Pressed A")
keyboard_controller.press(Key.space)
keyboard_controller.release(Key.space)
elif key.char == 'j':
print("Exiting program")
sys.exit()
except AttributeError:
pass
def on_release(key):
global a_pressed
try:
if key.char == 'a' and a_pressed:
a_pressed = False
print("Released A")
keyboard_controller.press(Key.space)
keyboard_controller.release(Key.space)
except AttributeError:
pass
with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()
*It should be noted that this was written with the assistance of ChatGPT, I’m still learning Python*
This is a simple script that simulates a press of the space bar whenever the letter “A” is released (spinning starts), and simulates it again when the letter “A” is pressed (spinning stops). This causes the space bar to be hit both when the motor starts to be spun, and when it stops being spun.
You might notice part of the script is for when “J” is pressed, and this is simply a means to stop the program with the ‘break’ method.
The Results
When you have a YouTube video on the screen thats currently paused, spinning the motor will ‘un-ground’ the “A” pin on the Makey Makey which sends that signal to the computer. The program on the computer sees that “A” is no longer being held down, so it hits space unpausing the video.
When you inevitably get tired and have to stop spinning the motor, the “A” pin becomes grounded through the motor, and the script hits the space bar again to pause the video.
Now I can rest easy knowing that as long as I’m watching YouTube, at least I’m getting a workout in.