@woakas CTO at Ubidots
PyConAr 2017
Noviembre 13, 2013
import machine
import time
pin = machine.Pin(2, machine.Pin.OUT)
for i in range(10):
pin.on()
time.sleep(1)
pin.off()
time.sleep(1)
import time
import machine
led = machine.Pin(2, machine.Pin.OUT)
eval("led.on()")
a = """import time
from machine import Pin
led = Pin(2, mode=Pin.OUT, value=0)
for i in range(10):
led.on()
time.sleep(0.1)
led.off()
time.sleep(0.1)
"""
with open('main.py', 'w') as f:
f.write(a)
import _thread
import time
def th_func(delay, id):
while True:
time.sleep(delay)
print('Running thread %d' % id)
for i in range(3):
_thread.start_new_thread(th_func, (i + 1, i))
import uasyncio
import uasyncio as asyncio
loop = asyncio.get_event_loop()
async def bar():
count = 0
while True:
count += 1
print(count)
await asyncio.sleep(1)
loop.create_task(bar())
loop.run_forever()