Created
December 31, 2025 09:45
-
-
Save makicamel/e92d8adc37e83028415be58ccfbd560a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| GPIOS = [4, 5, 9, 11, 13] | |
| sleep_range_start = 500 | |
| sleep_range_end = 5500 | |
| sleep_range = sleep_range_end - sleep_range_start + 1 | |
| seed = 1225 | |
| random = Proc.new { |seed| ((seed * 1103515245 + 12345) & 0x7fffffff) % sleep_range + sleep_range_start } | |
| pins = {} | |
| GPIOS.each do |no| | |
| seed = random.call(seed) | |
| pins[GPIO.new(no, GPIO::OUT)] = seed | |
| end | |
| sleep_mseconds = 300 | |
| loop do | |
| pins.each do |pin, slept| | |
| if slept < 0 | |
| pin.write((pin.read - 1).abs) | |
| seed = random.call(seed).abs | |
| pins[pin] = seed | |
| end | |
| pins[pin] -= sleep_mseconds | |
| end | |
| if pins.keys.all? { |pin| pin.read == 0 } | |
| pins.keys.first.write 1 | |
| end | |
| sleep_ms sleep_mseconds | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment