Skip to content

Commit

Permalink
Add script for Animal Crossing New Horizons
Browse files Browse the repository at this point in the history
  • Loading branch information
ebith committed Mar 25, 2020
1 parent 5c1920a commit a28e8fb
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions example/animal-crossing-new-horizons-buy-fruits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python3
import argparse
import serial
from time import sleep
import datetime

parser = argparse.ArgumentParser()
parser.add_argument('port')
args = parser.parse_args()

def send(msg, duration=0):
print(f'{datetime.datetime.now()} {msg}')
ser.write(f'{msg}\r\n'.encode('utf-8'))
sleep(duration)
ser.write(b'RELEASE\r\n')

ser = serial.Serial(args.port, 9600)

sleep(5)

try:
while True:
send('Button A', 0.1)
sleep(4)
send('Button A', 0.1)
sleep(1)
send('HAT BOTTOM', 0.1)
sleep(1)
send('Button A', 0.1)
sleep(1)
send('Button A', 0.1)
sleep(1)
send('Button A', 0.1)
sleep(3)
send('Button A', 0.1)
sleep(1)
except KeyboardInterrupt:
send('RELEASE')
ser.close()

0 comments on commit a28e8fb

Please sign in to comment.