[go: up one dir, main page]

0% found this document useful (0 votes)
27 views5 pages

Micro Python Code For Raspberry Pi Pico

Uploaded by

ROHITH KANNAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views5 pages

Micro Python Code For Raspberry Pi Pico

Uploaded by

ROHITH KANNAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

MICRO PYTHON CODE FOR RASPBERRY PI PICO – ONLINE

SIMULATION ( WOKWI)

1. TURN ON ONBOARD LED

from machine import Pin from machine import Pin


led = Pin(25, Pin.OUT) led = Pin(25, Pin.OUT)
led.toggle() led.value(1)

2. TURN ON EXTERNAL GPIO PIN LED

from machine import Pin from machine import Pin


led = Pin(5, Pin.OUT) led = Pin(5, Pin.OUT)
led.toggle() led.value(1)

MYTHILI A - 9025366987
3. BLINK ONBOARD LED (ON & OFF)
from machine import Pin
from time import sleep

led = Pin(25, Pin.OUT)

while True :
led.value(1)
sleep(0.5)
led.value(0)
sleep(0.5)

4. BLINK EXTERNAL LED (ON & OFF)

from machine import Pin


from time import sleep
led = Pin(15, Pin.OUT)

while True :
led.value(1)
sleep(0.5)
led.value(0)
sleep(0.5)

5. RGB LED TASK USING MICRO PYTHON


from machine import Pin
import utime
red = Pin(16, Pin.OUT)
green = Pin(18, Pin.OUT)
blue = Pin(20, Pin.OUT)
while True:
red.value(1)
green.value(0)
blue.value(0)
utime.sleep(1)

red.value(0)
green.value(1)
blue.value(0)
utime.sleep(1)

red.value(0)
green.value(0)
blue.value(1)
utime.sleep(1)

MYTHILI A - 9025366987
6. PUSH BUTTON TASK USING MICRO PYTHON

from machine import Pin


from time import sleep
button=Pin(14,Pin.IN,Pin.PULL_UP)
led=Pin(15,Pin.OUT)
while True:

check=button.value()
print(check)

if(check==0):
led.value(1)
else:
led.value(0)

MYTHILI A - 9025366987
7. 2 WAY SWITCH LOGIC WITH PUSH BUTTON USING MICRO PYTHON

from machine import Pin

from time import sleep


button1=Pin(13,Pin.IN,Pin.PULL_UP)
button2=Pin(14,Pin.IN,Pin.PULL_UP)
led=Pin(15,Pin.OUT)
while True:

check1=button1.value()
check2=button2.value()
print(check1,check2)
if((check1==0 and check2==1) or (check1==1 and check2==0)):
led.value(1)
else:
led.value(0)

8. ADC – TO PRINT ANALOG VALUES USING MICRO PYTHON ( POT )

from machine import ADC, Pin


import time

adc = ADC(Pin(26))

while True:
print(adc.read_u16())
time.sleep(1)

MYTHILI A - 9025366987
MYTHILI A - 9025366987

You might also like