#Program: Pico_Python_27Register.py #########
from micropython import const
from machine import Pin, mem32
import time
#Access Direct Registers here
GPIO_IN = const(0xD0000004)
GPIO_OUT = const(0xD0000010)
GPIO_OUT_SET = const(0xD0000014)
GPIO_OUT_CLR = const(0xD0000018)
GPIO_OUT_XOR = const(0xD000001C)
pin_SW1 = 14
pin_SW2 = 15
BIT1514 = const(0b01100000000000000)
#setup here
for LEDn in range(0, 8):
Pin(LEDn, Pin.OUT)
SW1 = Pin(pin_SW1, Pin.IN, Pin.PULL_UP)
SW2 = Pin(pin_SW2, Pin.IN, Pin.PULL_UP)
print("Hello Students,","8-LEDs : off")
#infinite loop here
while True:
flag_SW = BIT1514 & mem32[GPIO_IN]
if flag_SW:
mem32[GPIO_OUT_CLR] = 0b11111111
else:
mem32[GPIO_OUT_SET] = 0b11111111
time.sleep_ms(100)
print("state Input =",bin(flag_SW))
#END program here ##################