0% found this document useful (0 votes)
45 views79 pages

Pico Introduction

The document is a guide for introducing the Raspberry Pi Pico microcontroller. It discusses what the Pico is, its specifications and features. It then provides steps to set up the Pico development environment on your computer using Thonny IDE. The guide also teaches basic input/output operations using the built-in LED and button on the Pico board. It shows how to blink, pulse and fade the LED using Python code.

Uploaded by

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

Pico Introduction

The document is a guide for introducing the Raspberry Pi Pico microcontroller. It discusses what the Pico is, its specifications and features. It then provides steps to set up the Pico development environment on your computer using Thonny IDE. The guide also teaches basic input/output operations using the built-in LED and button on the Pico board. It shows how to blink, pulse and fade the LED using Python code.

Uploaded by

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

Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.

org/en/projects/introduction-to-the-pico/print

1 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

Ω Ω Ω

2 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

3 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

4 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

5 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

6 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

sudo apt update sudo apt upgrade -y

print('Hello World!')

7 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

8 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

9 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

10 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

11 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

12 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

13 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

14 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

15 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

16 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

17 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

18 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

from picozero import pico_led

pico_led.on()

19 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

20 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

22 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

Ω
Ω Ω

23 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

24 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

25 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print


Needed Resistance =
( , )

. − .
Needed Resistance = .

26 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

27 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

28 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

29 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

30 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

31 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

32 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

from picozero import LED

led LED(13)

from picozero import LED

led_1 LED(13)
led_2 LED(8)
led_3 LED(5)

red_led LED(13)
green_led LED(8)
pink_led LED(5)

from picozero import LED


from time import sleep

yellow LED(13)
yellow.on()
sleep(2)
yellow.off()

led.blink() # on for 1 second then off for one second


print("Blinking") # Runs immediately

sleep(6)
led.off()

led.blink(on_time 1, off_time 0.5, n 3, wait True)


print("Finished blinking") # Runs after 3 on/off blinks

33 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

led.pulse() # take 1 second to brighten and 1 second to dim


print("Pulsing") # Runs immediately

led.pulse(fade_in_time 2, fade_out_time 1, n 4, wait True) # take 2 seconds to brighten and 1 second to dim
print("Finished pulsing") # Runs after 4 pulses

led.blink(on_time 1, off_time 1, fade_in_time 1, fade_out_time 1) # On for 1 second, off for 1 second, fade between
print("Fancy") # Runs immediately

34 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

35 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

36 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

37 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

38 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

39 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

40 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

41 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

42 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

43 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

44 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

45 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

from picozero import RGBLED

rgb RGBLED(red 1, green 2, blue 3)

from picozero import RGBLED


from time import sleep

rgb RGBLED(red 1, green 2, blue 3)

while True:
rgb.color (255, 0, 0)
sleep(0.5)
rgb.color (0, 255, 0)
sleep(0.5)
rgb.color (0, 0, 255)
sleep(0.5)

46 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

rgb.blink() # red for 1 second, green for 1 second, blue for 1 second
print("Blinking") # Runs immediately

sleep(6)
rgb.off()

# blink purple 2 seconds, off 0.5 seconds


rgb.blink(on_times (2, 0.5), colors ((255, 0, 255), (0, 0, 0)), wait True, n 3)
print("Finished blinking") # Runs after 3 repeats

# blink red 1 second, green 0.5 seconds, blue 0.25 seconds


rgb.blink((1, 0.5, 0.25), colors ((255, 0, 0), (0, 255, 0), (0, 0, 255)), wait True, n 2)
print("Finished blinking") # Runs after 2 blink repeats

rgb.pulse() # pulse red for 1 second, green for 1 second, blue for 1 second
print("Pulsing") # Runs immediately

# 2 second to fade from purple to off, 0.5 seconds to change from off to purple
rgb.pulse(fade_times (2, 0.5), colors ((255, 0, 255), (0, 0, 0)), wait True, n 3)
print("Finished pulsing") # Runs after 3 pulses

rgb.cycle() # Gradually colour cycle through colours between red and green, green and blue then blue and red
print("Cycle") # Runs immediately

# Colour cycle slower in the opposite direction


rgb.cycle(fade_times 3, colors ((0, 0, 255), (0, 255, 0), (255, 0, 0)), wait True, n 2)
rgb.off()

47 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

48 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

49 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

50 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

from picozero import Speaker

speaker Speaker(5)

from picozero import Speaker

speaker_1 Speaker(5)
speaker_2 Speaker(10)

51 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

52 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

53 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

speaker.play(c_note, 0.1) # play the middle c for 0.1 seconds

BEAT 1 # a constant

speaker.play(c_note, BEAT) # play the middle c for 1 second

my_tune [ ['d5', 1], ['d#5', 0.5], ['f5', 1.2]] # the notes, along with the length of each note

1 BEAT 0.4 # The length of a note in a single beat


2
3 my_tune [ ['d5', BEAT], ['d#5', BEAT 2], ['f5', BEAT 1.5]] # the notes, along with the length of each note

54 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

speaker.play(523, 1) # Play the frequency 523 for 1 second

55 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

def c_note():
speaker.play('c4', 0.5) # play the middle c for half a second

56 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

BEAT 0.4

liten_mus [ ['d5', BEAT 2], ['d#5', BEAT 2], ['f5', BEAT], ['d6', BEAT], ['a#5', BEAT], ['d5', BEAT],
['f5', BEAT], ['d#5', BEAT], ['d#5', BEAT], ['c5', BEAT 2],['d5', BEAT 2], ['d#5', BEAT],
['c6', BEAT], ['a5', BEAT], ['d5', BEAT], ['g5', BEAT], ['f5', BEAT], ['f5', BEAT], ['d5', BEAT 2],
['d#5', BEAT 2], ['f5', BEAT], ['g5', BEAT], ['a5', BEAT], ['a#5', BEAT], ['a5', BEAT], ['g5', BEAT],
['g5', BEAT], ['', BEAT 2], ['a#5', BEAT 2], ['c6', BEAT 2], ['d6', BEAT 2], ['c6', BEAT 2],
['a#5', BEAT 2], ['a5', BEAT 2], ['g5', BEAT 2], ['a5', BEAT 2], ['a#5', BEAT 2], ['c6',
BEAT],
['f5', BEAT], ['f5', BEAT], ['f5', BEAT 2], ['d#5', BEAT 2], ['d5', BEAT], ['f5', BEAT], ['d6',
BEAT],
['d6', BEAT 2], ['c6', BEAT 2], ['b5', BEAT], ['g5', BEAT], ['g5', BEAT], ['c6', BEAT 2],
['a#5', BEAT 2], ['a5', BEAT], ['f5', BEAT], ['d6', BEAT], ['a5', BEAT], ['a#5', BEAT 1.5] ]

def play_liten_mus():
speaker.play(liten_mus)

BEAT 0.4

liten_mus [ ['d5', BEAT 2], ['d#5', BEAT 2], ['f5', BEAT], ['d6', BEAT], ['a#5', BEAT], ['d5', BEAT],
['f5', BEAT], ['d#5', BEAT], ['d#5', BEAT], ['c5', BEAT 2],['d5', BEAT 2], ['d#5', BEAT],
['c6', BEAT], ['a5', BEAT], ['d5', BEAT], ['g5', BEAT], ['f5', BEAT], ['f5', BEAT], ['d5', BEAT 2],
['d#5', BEAT 2], ['f5', BEAT], ['g5', BEAT], ['a5', BEAT], ['a#5', BEAT], ['a5', BEAT], ['g5', BEAT],
['g5', BEAT], ['', BEAT 2], ['a#5', BEAT 2], ['c6', BEAT 2], ['d6', BEAT 2], ['c6', BEAT 2],
['a#5', BEAT 2], ['a5', BEAT 2], ['g5', BEAT 2], ['a5', BEAT 2], ['a#5', BEAT 2], ['c6',
BEAT],
['f5', BEAT], ['f5', BEAT], ['f5', BEAT 2], ['d#5', BEAT 2], ['d5', BEAT], ['f5', BEAT], ['d6',
BEAT],
['d6', BEAT 2], ['c6', BEAT 2], ['b5', BEAT], ['g5', BEAT], ['g5', BEAT], ['c6', BEAT 2],
['a#5', BEAT 2], ['a5', BEAT], ['f5', BEAT], ['d6', BEAT], ['a5', BEAT], ['a#5', BEAT 1.5] ]

for note in liten_mus:


speaker.play(note)

def win(): # rising frequency


for i in range(2000, 5000, 100):
speaker.play(i, 0.05) # short duration

def chirp(): # series of high-pitched chirps


for _ in range(2): # decreasing frequency
for i in range(5000, 2999, 100):
speaker.play(i, 0.02) # very short duration
sleep(0.2)

57 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

from picozero import Speaker


from time import sleep
from random import randint

speaker Speaker(5)

for i in range(100):
speaker.play(randint(500, 5000), duration None)
sleep(0.001)
speaker.stop()
sleep(0.5)

BEAT 0.4

liten_mus [ ['d5', BEAT 2], ['d#5', BEAT 2], ['f5', BEAT], ['d6', BEAT], ['a#5', BEAT], ['d5', BEAT],
['f5', BEAT], ['d#5', BEAT], ['d#5', BEAT], ['c5', BEAT 2],['d5', BEAT 2], ['d#5', BEAT],
['c6', BEAT], ['a5', BEAT], ['d5', BEAT], ['g5', BEAT], ['f5', BEAT], ['f5', BEAT], ['d5', BEAT 2],
['d#5', BEAT 2], ['f5', BEAT], ['g5', BEAT], ['a5', BEAT], ['a#5', BEAT], ['a5', BEAT], ['g5', BEAT],
['g5', BEAT], ['', BEAT 2], ['a#5', BEAT 2], ['c6', BEAT 2], ['d6', BEAT 2], ['c6', BEAT 2],
['a#5', BEAT 2], ['a5', BEAT 2], ['g5', BEAT 2], ['a5', BEAT 2], ['a#5', BEAT 2], ['c6',
BEAT],
['f5', BEAT], ['f5', BEAT], ['f5', BEAT 2], ['d#5', BEAT 2], ['d5', BEAT], ['f5', BEAT], ['d6',
BEAT],
['d6', BEAT 2], ['c6', BEAT 2], ['b5', BEAT], ['g5', BEAT], ['g5', BEAT], ['c6', BEAT 2],
['a#5', BEAT 2], ['a5', BEAT], ['f5', BEAT], ['d6', BEAT], ['a5', BEAT], ['a#5', BEAT 1.5] ]

sound [ [523, 0.1], [None, 0.1], [523, 0.4] ]

def annoying_sound():
speaker2.play(sound, wait False) # don't delay the main code

button.when_pressed annoying_sound

try:
speaker.play(liten_mus)
finally:
speaker.off() # turns speaker off when code is stopped by user
speaker2.off() # turns speaker2 off when code is stopped by user

58 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

59 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

60 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

61 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

62 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

63 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

64 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

65 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

66 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

67 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

from picozero import Button

button Button(18)

from picozero import Button

button_1 Button(18)
button_2 Button(22)
button_3 Button(28)

from picozero import Switch

switch Switch(18)

68 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

from picozero import Switch

switch_1 Switch(18)
switch_2 Switch(22)
switch_3 Switch(28)

button_1.when_pressed function_1
button_2.when_pressed function_2
button_3.when_pressed function_3

option 0 # store the current option

def choice(): # call the next function and update the option
global option
if option 0:
rgb.color (255, 0, 0)
elif option 1:
rgb.color (0, 255, 0)
elif option 2:
rgb.color (0, 0, 255)
elif option 3:
rgb.off()

# move to the next option


if option 3:
option 0
else:
option option 1

button.when_pressed choice # Call the choice function when the button is pressed

69 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

70 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

from picozero import Pot

dial Pot(0) # Connected to pin A0 (GP_26)

71 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

1 from picozero import Pot # Pot is short for Potentiometer


2 from time import sleep
3
4 dial Pot(0) # Connected to pin A0 (GP_26)
5
6 while True:
7 print(dial.value)
8 sleep(0.1) # slow down the output

while True:
function_to_call dial.percent
print(function_to_call)
if function_to_call 20:
function_1()
elif function_to_call 40:
function_2()
elif function_to_call 60:
function_3()
elif function_to_call 80:
function_4()
else:
function_5()
sleep(0.1)

72 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

BEAT 0.4

liten_mus [ ['d5', BEAT 2], ['d#5', BEAT 2], ['f5', BEAT], ['d6', BEAT], ['a#5', BEAT], ['d5', BEAT],
['f5', BEAT], ['d#5', BEAT], ['d#5', BEAT], ['c5', BEAT 2],['d5', BEAT 2], ['d#5', BEAT],
['c6', BEAT], ['a5', BEAT], ['d5', BEAT], ['g5', BEAT], ['f5', BEAT], ['f5', BEAT], ['d5', BEAT 2],
['d#5', BEAT 2], ['f5', BEAT], ['g5', BEAT], ['a5', BEAT], ['a#5', BEAT], ['a5', BEAT], ['g5', BEAT],
['g5', BEAT], ['', BEAT 2], ['a#5', BEAT 2], ['c6', BEAT 2], ['d6', BEAT 2], ['c6', BEAT 2],
['a#5', BEAT 2], ['a5', BEAT 2], ['g5', BEAT 2], ['a5', BEAT 2], ['a#5', BEAT 2], ['c6',
BEAT],
['f5', BEAT], ['f5', BEAT], ['f5', BEAT 2], ['d#5', BEAT 2], ['d5', BEAT], ['f5', BEAT], ['d6',
BEAT],
['d6', BEAT 2], ['c6', BEAT 2], ['b5', BEAT], ['g5', BEAT], ['g5', BEAT], ['c6', BEAT 2],
['a#5', BEAT 2], ['a5', BEAT], ['f5', BEAT], ['d6', BEAT], ['a5', BEAT], ['a#5', BEAT 1.5]]

for note in liten_mus:


speaker.play(note)
sleep(dial.value) # leave a gap between notes depending on potentiometer value

73 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

74 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

1 from machine import Pin, Timer


2 led Pin(25, Pin.OUT)
3 timer Timer()
4
5 def blink(timer):
6 led.toggle()
7
8 timer.init(freq 10, mode Timer.PERIODIC, callback blink)

75 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

76 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

77 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

78 of 79 2023-07-26, 05:27 pm
Introduction to Raspberry Pi Pico guide https://projects.raspberrypi.org/en/projects/introduction-to-the-pico/print

79 of 79 2023-07-26, 05:27 pm

You might also like