Skip to content

Instantly share code, notes, and snippets.

@dglaude
Created March 22, 2017 00:25
Show Gist options
  • Save dglaude/59bc0ea61eae8cb8404efb4278992d8a to your computer and use it in GitHub Desktop.
Save dglaude/59bc0ea61eae8cb8404efb4278992d8a to your computer and use it in GitHub Desktop.
ESP8266+Micropython+LDR+Servo=PokemonGo Plus Automation
f=open('main.py','w')
f.write('''import pokemon
pokemon.main()''')
f.close()
f=open('pokemon.py','w')
f.write('''import machine, time
p12 = machine.Pin(12)
adc = machine.ADC(0)
servo = machine.PWM(p12, freq=50)
def push():
global servo
servo.duty(55)
time.sleep_ms(500)
servo.duty(65)
time.sleep_ms(200)
servo.duty(75)
time.sleep_ms(200)
servo.duty(85)
time.sleep_ms(200)
servo.duty(95)
time.sleep_ms(200)
servo.duty(105)
time.sleep_ms(200)
servo.duty(0)
def main():
servo.duty(105)
time.sleep_ms(1000)
servo.duty(0)
while True:
if adc.read() > 1000:
time.sleep_ms(1000)
push()
time.sleep_ms(10000)
''')
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment