Article Index

Page 44

from machine import Pin
import time

pin = Pin(2, Pin.OUT)
while True:
    pin.value(1)
    time.sleep(1)
    pin.value(0)
    time.sleep(1)

Page 46

from machine import Pin
import time
def toggle(pin):
    temp = pin.value()
    temp = not temp
    pin.value(temp)

pin = Pin(2,Pin.OUT)
while True:
    toggle(pin)
    time.sleep(1)