diff --git a/ar-SA/images/220-resistor.png b/ar-SA/images/220-resistor.png new file mode 100644 index 0000000..3b902b0 Binary files /dev/null and b/ar-SA/images/220-resistor.png differ diff --git a/ar-SA/images/75-resistor.png b/ar-SA/images/75-resistor.png new file mode 100644 index 0000000..592d9f8 Binary files /dev/null and b/ar-SA/images/75-resistor.png differ diff --git a/ar-SA/images/Pico-Top-Headers.png b/ar-SA/images/Pico-Top-Headers.png new file mode 100644 index 0000000..4307098 Binary files /dev/null and b/ar-SA/images/Pico-Top-Headers.png differ diff --git a/ar-SA/images/Pico-onboard-LED.jpeg b/ar-SA/images/Pico-onboard-LED.jpeg new file mode 100644 index 0000000..eeed195 Binary files /dev/null and b/ar-SA/images/Pico-onboard-LED.jpeg differ diff --git a/ar-SA/images/banner.png b/ar-SA/images/banner.png new file mode 100644 index 0000000..bd5d0d1 Binary files /dev/null and b/ar-SA/images/banner.png differ diff --git a/ar-SA/images/buzzer-diagram.png b/ar-SA/images/buzzer-diagram.png new file mode 100644 index 0000000..46c31eb Binary files /dev/null and b/ar-SA/images/buzzer-diagram.png differ diff --git a/ar-SA/images/buzzer-diagram.psd b/ar-SA/images/buzzer-diagram.psd new file mode 100644 index 0000000..5607089 Binary files /dev/null and b/ar-SA/images/buzzer-diagram.psd differ diff --git a/ar-SA/images/community-galleries.png b/ar-SA/images/community-galleries.png new file mode 100644 index 0000000..e6ff637 Binary files /dev/null and b/ar-SA/images/community-galleries.png differ diff --git a/ar-SA/images/led-on-off.gif b/ar-SA/images/led-on-off.gif new file mode 100644 index 0000000..00fa96b Binary files /dev/null and b/ar-SA/images/led-on-off.gif differ diff --git a/ar-SA/images/led-on.jpeg b/ar-SA/images/led-on.jpeg new file mode 100644 index 0000000..c439bdd Binary files /dev/null and b/ar-SA/images/led-on.jpeg differ diff --git a/ar-SA/images/no-pico-interpreter.png b/ar-SA/images/no-pico-interpreter.png new file mode 100644 index 0000000..b7e8b5a Binary files /dev/null and b/ar-SA/images/no-pico-interpreter.png differ diff --git a/ar-SA/images/pico-bottom.png b/ar-SA/images/pico-bottom.png new file mode 100644 index 0000000..80aac38 Binary files /dev/null and b/ar-SA/images/pico-bottom.png differ diff --git a/ar-SA/images/pico-firmware-error.png b/ar-SA/images/pico-firmware-error.png new file mode 100644 index 0000000..e4942ea Binary files /dev/null and b/ar-SA/images/pico-firmware-error.png differ diff --git a/ar-SA/images/pico-hand.png b/ar-SA/images/pico-hand.png new file mode 100644 index 0000000..bd5d0d1 Binary files /dev/null and b/ar-SA/images/pico-hand.png differ diff --git a/ar-SA/images/pico-top-plug.png b/ar-SA/images/pico-top-plug.png new file mode 100644 index 0000000..73018aa Binary files /dev/null and b/ar-SA/images/pico-top-plug.png differ diff --git a/ar-SA/images/pico_led_13_bb.png b/ar-SA/images/pico_led_13_bb.png new file mode 100644 index 0000000..c0c4c2a Binary files /dev/null and b/ar-SA/images/pico_led_13_bb.png differ diff --git a/ar-SA/images/pot-diagram.png b/ar-SA/images/pot-diagram.png new file mode 100644 index 0000000..71d4fd6 Binary files /dev/null and b/ar-SA/images/pot-diagram.png differ diff --git a/ar-SA/images/potentiometer-illustration.png b/ar-SA/images/potentiometer-illustration.png new file mode 100644 index 0000000..714df76 Binary files /dev/null and b/ar-SA/images/potentiometer-illustration.png differ diff --git a/ar-SA/images/potentiometer.jpg b/ar-SA/images/potentiometer.jpg new file mode 100644 index 0000000..a189eb2 Binary files /dev/null and b/ar-SA/images/potentiometer.jpg differ diff --git a/ar-SA/images/repl-connected.png b/ar-SA/images/repl-connected.png new file mode 100644 index 0000000..0eae709 Binary files /dev/null and b/ar-SA/images/repl-connected.png differ diff --git a/ar-SA/images/resistor_datasheet.png b/ar-SA/images/resistor_datasheet.png new file mode 100644 index 0000000..dd33020 Binary files /dev/null and b/ar-SA/images/resistor_datasheet.png differ diff --git a/ar-SA/images/rgb-led-buzzer-diagram.png b/ar-SA/images/rgb-led-buzzer-diagram.png new file mode 100644 index 0000000..d6d27a1 Binary files /dev/null and b/ar-SA/images/rgb-led-buzzer-diagram.png differ diff --git a/ar-SA/images/rgb-led-diagram.png b/ar-SA/images/rgb-led-diagram.png new file mode 100644 index 0000000..f2d9544 Binary files /dev/null and b/ar-SA/images/rgb-led-diagram.png differ diff --git a/ar-SA/images/save-on-computer.png b/ar-SA/images/save-on-computer.png new file mode 100644 index 0000000..ba1c48c Binary files /dev/null and b/ar-SA/images/save-on-computer.png differ diff --git a/ar-SA/images/thonny-editor.png b/ar-SA/images/thonny-editor.png new file mode 100644 index 0000000..bd1197d Binary files /dev/null and b/ar-SA/images/thonny-editor.png differ diff --git a/ar-SA/images/thonny-install-micropython-pico.png b/ar-SA/images/thonny-install-micropython-pico.png new file mode 100644 index 0000000..0ad8443 Binary files /dev/null and b/ar-SA/images/thonny-install-micropython-pico.png differ diff --git a/ar-SA/images/thonny-install-package.jpg b/ar-SA/images/thonny-install-package.jpg new file mode 100644 index 0000000..74083ba Binary files /dev/null and b/ar-SA/images/thonny-install-package.jpg differ diff --git a/ar-SA/images/thonny-install-package.png b/ar-SA/images/thonny-install-package.png new file mode 100644 index 0000000..203c170 Binary files /dev/null and b/ar-SA/images/thonny-install-package.png differ diff --git a/ar-SA/images/thonny-manage-packages.jpg b/ar-SA/images/thonny-manage-packages.jpg new file mode 100644 index 0000000..320588d Binary files /dev/null and b/ar-SA/images/thonny-manage-packages.jpg differ diff --git a/ar-SA/images/thonny-manage-packages.png b/ar-SA/images/thonny-manage-packages.png new file mode 100644 index 0000000..773ad3e Binary files /dev/null and b/ar-SA/images/thonny-manage-packages.png differ diff --git a/ar-SA/images/thonny-packages-picozero.jpg b/ar-SA/images/thonny-packages-picozero.jpg new file mode 100644 index 0000000..7bb632d Binary files /dev/null and b/ar-SA/images/thonny-packages-picozero.jpg differ diff --git a/ar-SA/images/thonny-packages-picozero.png b/ar-SA/images/thonny-packages-picozero.png new file mode 100644 index 0000000..0e584a3 Binary files /dev/null and b/ar-SA/images/thonny-packages-picozero.png differ diff --git a/ar-SA/images/thonny-plotter.gif b/ar-SA/images/thonny-plotter.gif new file mode 100644 index 0000000..3180c82 Binary files /dev/null and b/ar-SA/images/thonny-plotter.gif differ diff --git a/ar-SA/meta.yml b/ar-SA/meta.yml new file mode 100644 index 0000000..2fe5db9 --- /dev/null +++ b/ar-SA/meta.yml @@ -0,0 +1,37 @@ +--- +title: Introduction to Raspberry Pi Pico guide +hero_image: images/banner.png +description: introduction-to-the-pico description +version: 4 +listed: true +copyedit: false +last_tested: '2022-01-10' +steps: + - + title: Introduction + - + title: Meet Raspberry Pi Pico + - + title: Install Thonny + - + title: Add the MicroPython firmware + - + title: Use the picozero library + - + title: Use the shell + - + title: Resistors + - + title: LEDs + - + title: RGB LEDs + - + title: Passive Buzzers + - + title: Buttons and switches + - + title: Potentiometers + - + title: Powering your Pico + - + title: Our Raspberry Pi Pico projects diff --git a/ar-SA/pico-comments.txt b/ar-SA/pico-comments.txt new file mode 100644 index 0000000..2f1f5c0 --- /dev/null +++ b/ar-SA/pico-comments.txt @@ -0,0 +1,15 @@ +store the current option + +call the next function and update the option + +move to the next option + +Call the choice function when the button is pressed + +Pot is short for Potentiometer + +Connected to pin A0 (GP_26) + +slow down the output + +leave a gap between notes depending on potentiometer value diff --git a/ar-SA/pico-translatable.txt b/ar-SA/pico-translatable.txt new file mode 100644 index 0000000..dc5d367 --- /dev/null +++ b/ar-SA/pico-translatable.txt @@ -0,0 +1,31 @@ +yellow + +rgb + +button_1 + +button_2 + +button_3 + +function_1 + +function_2 + +function_3 + +option + +choice + +dial + +function_to_call + +BEAT + +listen_mus + +note + +speaker diff --git a/ar-SA/step_1.md b/ar-SA/step_1.md new file mode 100644 index 0000000..33c1d9a --- /dev/null +++ b/ar-SA/step_1.md @@ -0,0 +1,54 @@ +## Introduction +This guide shows you how to connect a Raspberry Pi Pico to another computer and program it using the `picozero` beginner library with MicroPython. + +### What is the Raspberry Pi Pico? +A Raspberry Pi Pico is a low-cost microcontroller device. Microcontrollers are tiny computers, but they tend to lack large volume storage and peripheral devices that you can plug in (for example, keyboards or monitors). + +A Raspberry Pi Pico has GPIO pins, much like a Raspberry Pi computer, which means it can be used to control and receive input from a variety of electronic devices. + + + +--- collapse --- +--- +title: What you will need +--- +### Hardware + ++ A Raspberry Pi Pico with soldered headers ++ A computer that can run the Thonny IDE and program a Raspberry Pi Pico ++ A micro USB data cable ++ An external 5V micro USB power source (optional) + +To complete the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path: + ++ 1 red LED ++ 1 yellow LED ++ A selection of other single-colour LEDs ++ At least one **common cathode** RGB LED ++ At least one potentiometer ++ At least one passive buzzer ++ At least four push buttons ++ 100Ω resistors (any resistor from 75Ω-220Ω will work) 3 per RGB LED, 1 per single colour LED ++ A selection of socket-to-socket jumper leads and socket-pin jumper leads. + +When purchasing jumper wires you may notice that they are called male-male (m-m), female-female (f-f) and male-female (m-f). This is legacy (prior) language used to describe the ends of the wires. Pin and socket are more inclusive terms that should now be used to describe jumper wires. + +**Note:** You can reuse components in multiple projects. If you have additional components then you won't have to take each project apart to make the next one. + +### Software + +The project will guide you through the installation of: + ++ The Thonny Python IDE ++ MicroPython firmware for Raspberry Pi Pico ++ The picozero library + +--- /collapse --- + +### How to use this reference guide + +If you have not used a Raspberry Pi Pico before, then this guide will help you to get set up and create your first program. Then you will be ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + +You can return to this guide and use it to look up information that you need when you are making your own projects with the Raspberry Pi Pico. + +**Note:** Advanced MicroPython users can use [Getting Started with Raspberry Pi Pico](https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico). \ No newline at end of file diff --git a/ar-SA/step_10.md b/ar-SA/step_10.md new file mode 100644 index 0000000..c5d4bcc --- /dev/null +++ b/ar-SA/step_10.md @@ -0,0 +1,43 @@ +## Passive Buzzers + +There are two main types of buzzer, an **active** buzzer and a **passive** buzzer. An **active** buzzer always plays the same tone. A **passive** buzzer can play a variety of tones. It requires a connection to be made and a specific signal to play the chosen tone. + +[[[buzzers-speakers]]] + +Some passive buzzers can be connected without worrying about which pin is connected to ground, and which pin is connected to a GPIO pin on the Raspberry Pi Pico. Others have to be connected in a specific way and will normally have a **+** symbol on the surface, to tell you which pin needs connecting to the GPIO signal pin + + + +Here is how you could wire your buzzers to a Raspberry Pi Pico: + +\[[[single-buzzer-wire]]\] \[[[stereo-buzzer-wiring\]]] [[[earphones-wiring]]] + +Set up your buzzer in your code: + +\[[[single-buzzer-pin]]\] \[[[multiple-buzzer-pins\]]] + +Humans can hear sounds in the range 20 Hz (very low) to 20,000 Hz (very high). Children and young people can hear higher sounds than older people. Musical notes correspond to specific sound **frequencies**, for example the middle C (C4) is about 523 Hz. Hz, short for Hertz, is the number of vibrations per second. Sending the right signal to a buzzer will make it vibrate at a particular frequency which you will hear as a musical note. + +There are many things you can do with buzzers, here is some useful information and a couple of ideas: + +[[[list-of-notes]]] + +[[[note-length]]] + +[[[frequency-numbers]]] + +[[[sheet-to-notes]]] + +[[[play-single-note]]] + +[[[play-a-tune]]] + +[[[notes-in-loop]]] + +[[[pico-sound-frequency]]] + +[[[whitenoise-drum-beat]]] + +[[[interrupt-tune]]] + +[[[sharing-a-ground-pin]]] diff --git a/ar-SA/step_11.md b/ar-SA/step_11.md new file mode 100644 index 0000000..77c1777 --- /dev/null +++ b/ar-SA/step_11.md @@ -0,0 +1,74 @@ +## Buttons and switches + +The Raspberry Pi Pico can detect when an input is connected between GND and one of the GP pins. + +
+A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/ar-SA/step_12.md b/ar-SA/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/ar-SA/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/ar-SA/step_13.md b/ar-SA/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/ar-SA/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/ar-SA/step_14.md b/ar-SA/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/ar-SA/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/ar-SA/step_2.md b/ar-SA/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/ar-SA/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/ar-SA/step_3.md b/ar-SA/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/ar-SA/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/ar-SA/step_4.md b/ar-SA/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/ar-SA/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/ar-SA/step_5.md b/ar-SA/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/ar-SA/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/ar-SA/step_6.md b/ar-SA/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/ar-SA/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/ar-SA/step_7.md b/ar-SA/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/ar-SA/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/ar-SA/step_8.md b/ar-SA/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/ar-SA/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/cy-GB/step_12.md b/cy-GB/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/cy-GB/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/cy-GB/step_13.md b/cy-GB/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/cy-GB/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/cy-GB/step_14.md b/cy-GB/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/cy-GB/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/cy-GB/step_2.md b/cy-GB/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/cy-GB/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/cy-GB/step_3.md b/cy-GB/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/cy-GB/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/cy-GB/step_4.md b/cy-GB/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/cy-GB/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/cy-GB/step_5.md b/cy-GB/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/cy-GB/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/cy-GB/step_6.md b/cy-GB/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/cy-GB/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/cy-GB/step_7.md b/cy-GB/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/cy-GB/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/cy-GB/step_8.md b/cy-GB/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/cy-GB/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/el-GR/step_12.md b/el-GR/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/el-GR/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/el-GR/step_13.md b/el-GR/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/el-GR/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/el-GR/step_14.md b/el-GR/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/el-GR/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/el-GR/step_2.md b/el-GR/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/el-GR/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/el-GR/step_3.md b/el-GR/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/el-GR/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/el-GR/step_4.md b/el-GR/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/el-GR/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/el-GR/step_5.md b/el-GR/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/el-GR/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/el-GR/step_6.md b/el-GR/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/el-GR/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/el-GR/step_7.md b/el-GR/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/el-GR/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/el-GR/step_8.md b/el-GR/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/el-GR/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/en-US/step_12.md b/en-US/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/en-US/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/en-US/step_13.md b/en-US/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/en-US/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/en-US/step_14.md b/en-US/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/en-US/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/en-US/step_2.md b/en-US/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/en-US/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/en-US/step_3.md b/en-US/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/en-US/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/en-US/step_4.md b/en-US/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/en-US/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/en-US/step_5.md b/en-US/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/en-US/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/en-US/step_6.md b/en-US/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/en-US/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/en-US/step_7.md b/en-US/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/en-US/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/en-US/step_8.md b/en-US/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/en-US/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/es-LA/step_12.md b/es-LA/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/es-LA/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/es-LA/step_13.md b/es-LA/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/es-LA/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/es-LA/step_14.md b/es-LA/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/es-LA/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/es-LA/step_2.md b/es-LA/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/es-LA/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/es-LA/step_3.md b/es-LA/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/es-LA/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/es-LA/step_4.md b/es-LA/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/es-LA/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/es-LA/step_5.md b/es-LA/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/es-LA/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/es-LA/step_6.md b/es-LA/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/es-LA/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/es-LA/step_7.md b/es-LA/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/es-LA/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/es-LA/step_8.md b/es-LA/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/es-LA/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/fr-FR/step_12.md b/fr-FR/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/fr-FR/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/fr-FR/step_13.md b/fr-FR/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/fr-FR/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/fr-FR/step_14.md b/fr-FR/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/fr-FR/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/fr-FR/step_2.md b/fr-FR/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/fr-FR/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/fr-FR/step_3.md b/fr-FR/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/fr-FR/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/fr-FR/step_4.md b/fr-FR/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/fr-FR/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/fr-FR/step_5.md b/fr-FR/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/fr-FR/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/fr-FR/step_6.md b/fr-FR/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/fr-FR/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/fr-FR/step_7.md b/fr-FR/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/fr-FR/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/fr-FR/step_8.md b/fr-FR/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/fr-FR/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/hi-IN/step_12.md b/hi-IN/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/hi-IN/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/hi-IN/step_13.md b/hi-IN/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/hi-IN/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/hi-IN/step_14.md b/hi-IN/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/hi-IN/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/hi-IN/step_2.md b/hi-IN/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/hi-IN/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/hi-IN/step_3.md b/hi-IN/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/hi-IN/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/hi-IN/step_4.md b/hi-IN/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/hi-IN/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/hi-IN/step_5.md b/hi-IN/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/hi-IN/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/hi-IN/step_6.md b/hi-IN/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/hi-IN/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/hi-IN/step_7.md b/hi-IN/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/hi-IN/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/hi-IN/step_8.md b/hi-IN/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/hi-IN/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/hu-HU/step_12.md b/hu-HU/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/hu-HU/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/hu-HU/step_13.md b/hu-HU/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/hu-HU/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/hu-HU/step_14.md b/hu-HU/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/hu-HU/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/hu-HU/step_2.md b/hu-HU/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/hu-HU/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/hu-HU/step_3.md b/hu-HU/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/hu-HU/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/hu-HU/step_4.md b/hu-HU/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/hu-HU/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/hu-HU/step_5.md b/hu-HU/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/hu-HU/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/hu-HU/step_6.md b/hu-HU/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/hu-HU/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/hu-HU/step_7.md b/hu-HU/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/hu-HU/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/hu-HU/step_8.md b/hu-HU/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/hu-HU/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/ja-JP/step_12.md b/ja-JP/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/ja-JP/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/ja-JP/step_13.md b/ja-JP/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/ja-JP/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/ja-JP/step_14.md b/ja-JP/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/ja-JP/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/ja-JP/step_2.md b/ja-JP/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/ja-JP/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/ja-JP/step_3.md b/ja-JP/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/ja-JP/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/ja-JP/step_4.md b/ja-JP/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/ja-JP/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/ja-JP/step_5.md b/ja-JP/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/ja-JP/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/ja-JP/step_6.md b/ja-JP/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/ja-JP/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/ja-JP/step_7.md b/ja-JP/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/ja-JP/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/ja-JP/step_8.md b/ja-JP/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/ja-JP/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/kn-IN/step_12.md b/kn-IN/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/kn-IN/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/kn-IN/step_13.md b/kn-IN/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/kn-IN/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/kn-IN/step_14.md b/kn-IN/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/kn-IN/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/kn-IN/step_2.md b/kn-IN/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/kn-IN/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/kn-IN/step_3.md b/kn-IN/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/kn-IN/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/kn-IN/step_4.md b/kn-IN/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/kn-IN/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/kn-IN/step_5.md b/kn-IN/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/kn-IN/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/kn-IN/step_6.md b/kn-IN/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/kn-IN/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/kn-IN/step_7.md b/kn-IN/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/kn-IN/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/kn-IN/step_8.md b/kn-IN/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/kn-IN/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/mr-IN/step_12.md b/mr-IN/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/mr-IN/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/mr-IN/step_13.md b/mr-IN/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/mr-IN/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/mr-IN/step_14.md b/mr-IN/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/mr-IN/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/mr-IN/step_2.md b/mr-IN/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/mr-IN/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/mr-IN/step_3.md b/mr-IN/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/mr-IN/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/mr-IN/step_4.md b/mr-IN/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/mr-IN/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/mr-IN/step_5.md b/mr-IN/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/mr-IN/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/mr-IN/step_6.md b/mr-IN/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/mr-IN/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/mr-IN/step_7.md b/mr-IN/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/mr-IN/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/mr-IN/step_8.md b/mr-IN/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/mr-IN/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/nl-NL/step_12.md b/nl-NL/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/nl-NL/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/nl-NL/step_13.md b/nl-NL/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/nl-NL/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/nl-NL/step_14.md b/nl-NL/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/nl-NL/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/nl-NL/step_2.md b/nl-NL/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/nl-NL/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/nl-NL/step_3.md b/nl-NL/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/nl-NL/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/nl-NL/step_4.md b/nl-NL/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/nl-NL/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/nl-NL/step_5.md b/nl-NL/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/nl-NL/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/nl-NL/step_6.md b/nl-NL/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/nl-NL/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/nl-NL/step_7.md b/nl-NL/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/nl-NL/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/nl-NL/step_8.md b/nl-NL/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/nl-NL/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/pl-PL/step_12.md b/pl-PL/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/pl-PL/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/pl-PL/step_13.md b/pl-PL/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/pl-PL/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/pl-PL/step_14.md b/pl-PL/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/pl-PL/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/pl-PL/step_2.md b/pl-PL/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/pl-PL/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/pl-PL/step_3.md b/pl-PL/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/pl-PL/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/pl-PL/step_4.md b/pl-PL/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/pl-PL/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/pl-PL/step_5.md b/pl-PL/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/pl-PL/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/pl-PL/step_6.md b/pl-PL/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/pl-PL/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/pl-PL/step_7.md b/pl-PL/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/pl-PL/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/pl-PL/step_8.md b/pl-PL/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/pl-PL/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/pt-BR/step_12.md b/pt-BR/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/pt-BR/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/pt-BR/step_13.md b/pt-BR/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/pt-BR/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/pt-BR/step_14.md b/pt-BR/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/pt-BR/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/pt-BR/step_2.md b/pt-BR/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/pt-BR/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/pt-BR/step_3.md b/pt-BR/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/pt-BR/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/pt-BR/step_4.md b/pt-BR/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/pt-BR/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/pt-BR/step_5.md b/pt-BR/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/pt-BR/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/pt-BR/step_6.md b/pt-BR/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/pt-BR/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/pt-BR/step_7.md b/pt-BR/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/pt-BR/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/pt-BR/step_8.md b/pt-BR/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/pt-BR/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + ++A switch is a an electrical component that can be **closed** to allow electrical current to flow and **open** to prevent electrical current from flowing. A button is a kind of momentary switch that makes a connection only when it is **pressed**. +
+ +The simplest kind of switch is two jumper wires that can be connected together to close the switch, or separated to open the switch. The most common type of button is a Push Button Switch but there are many types of buttons and switches that can be bought or crafted. Here are a couple of crafted ideas you could try: + +\[[[drop-switch]]\] \[[[pull-switch\]]] + +Here is how you could wire buttons and switches to a Raspberry Pi Pico: + +\[[[single-button-wiring]]\] \[[[multiple-button-wiring\]]] \[[[crafted-switch-button-wiring]]\] \[[[multiple-crafted-switch-button-wiring\]]] + +Set up your button or switch in your code: + +\[[[single-button-pins]]\] \[[[multiple-button-pins\]]] \[[[single-switch-pins]]\] \[[[multiple-switches-pins\]]] + +There are many things you can do with buttons and switches, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a different function when each button is pressed +--- + +You can have multiple buttons that each call a different function when they are pressed. + +Make sure you use the function names from your project and just use the name of the function, do not call it by adding brackets. + +--- code --- +--- +language: python +--- + +button_1.when_pressed = function_1 button_2.when_pressed = function_2 button_3.when_pressed = function_3 + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change to the next function when a single button is pressed +--- + +Use an `option` variable to keep track of the current function so that you can decide which function to call next. + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- + diff --git a/ru-RU/step_12.md b/ru-RU/step_12.md new file mode 100644 index 0000000..aeca7e2 --- /dev/null +++ b/ru-RU/step_12.md @@ -0,0 +1,88 @@ +## Potentiometers + +A potentiometer is a resistor that allows you to change the value of the resistance. They are often just called **pots**. + +Turning the dial on the top of the potentiometer will change the resistance of the potentiometer, which can then be read by the Raspberry Pi Pico. + + + +A potentiometer has three pins. The outer pins are normally connected to a 3V3 pin and a GND pin. The middle pin is connected to a GPIO pin capable of reading an analogue signal: + +{:width="300px"} + +Here is how you could wire a potentiometer to a Raspberry Pi Pico: + +[[[potentiometer-wiring]]] + +Set up your potentiometer in your code: + +[[[potentiometer-pin]]] + +The Thonny plotter allows you to display the values so you can see the effect of turning the dial. In Thonny, choose 'View > Plotter' and the plotter will appear next to the Shell. + + + +The following code will read a value from the potentiometer and print out the result: + +--- code --- +--- +language: python filename: line_numbers: true line_number_start: 1 +line_highlights: +--- +from picozero import Pot # Pot is short for Potentiometer from time import sleep + +dial = Pot(0) # Connected to pin A0 (GP_26) + +while True: print(dial.value) sleep(0.1) # slow down the output + +--- /code --- + +The `sleep(0.1)` line slows down the reading and printing of values from the potentiometer so that Thonny can keep up with the output. + +The value should be 0 (or close to 0) when the potentiometer is turned all the way to the left and 1 (or close to 1) when it is turned all the way to the right. If your values are the wrong way round you need to swap the jumper wires connected to GND and 3V3. + +There are many things you can do with a potentiometer, here are a couple of ideas: + +--- collapse --- + +--- +title: Call a function based on the value of the potentiometer +--- + +If you are using a potentiometer to control outputs then you will need to divide up the dial into equal sections. + +You can use `dial.percent` to get a value between 0 and 1 from the potentiometer. If you have 5 sections then you can check whether the value is less than 20, 40, 60, 80 or 100. If you have 3 sections then you can check whether the value is less that 33, 66 or 100. + +--- code --- +--- +language: python +--- + +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) + +--- /code --- + +--- /collapse --- + +--- collapse --- + +--- +title: Change the speed of a tune using a potentiometer +--- + +You can use a potentiometer to control the speed of a tune when the tune is playing: + +--- code --- +--- +language: python +--- +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 + +--- /code --- + +--- /collapse --- \ No newline at end of file diff --git a/ru-RU/step_13.md b/ru-RU/step_13.md new file mode 100644 index 0000000..3266ac7 --- /dev/null +++ b/ru-RU/step_13.md @@ -0,0 +1,16 @@ +## Powering your Pico + +If you want to run your Raspberry Pi Pico without it being attached to a computer, you need to use a USB power supply or a suitable battery pack and connectors. + +Safe operating voltages are between 1.8V and 5.5V. + +To automatically run a MicroPython program, simply save it to the device with the name `main.py` + +[[[run-python-main-pico]]] + +To power the Raspberry Pi Pico away from a computer, you need a suitable power supply: + +[[[power-pico-usb]]] + +[[[power-pico-aa]]] + diff --git a/ru-RU/step_14.md b/ru-RU/step_14.md new file mode 100644 index 0000000..f2fb08b --- /dev/null +++ b/ru-RU/step_14.md @@ -0,0 +1,15 @@ +## Our Raspberry Pi Pico projects + +Our beginner level [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path has six projects to introduce digital making with the Raspberry Pi Pico. + +In the path you will learn how to connect and control LEDs, buttons, switches, buzzers and potentiometers. You will make: ++ An LED firefly ++ A party popper ++ Beating heart ++ Mood indicator ++ Sound machine ++ Sensory gadget + +**Get inspired:** take a look at our [Community galleries](https://wakelet.com/@Intro_to_Pico){:target="_blank"} to see the types of things you will be able to make when you complete our [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. + + \ No newline at end of file diff --git a/ru-RU/step_2.md b/ru-RU/step_2.md new file mode 100644 index 0000000..dbadadf --- /dev/null +++ b/ru-RU/step_2.md @@ -0,0 +1,25 @@ +## Meet Raspberry Pi Pico + +This is a Raspberry Pi Pico. Hopefully your device has already had the header pins soldered on, but if not, you might like to have a look at our [Getting started with soldering resource](https://projects.raspberrypi.org/en/projects/getting-started-with-soldering). + + + +--- task --- + +Plug your micro USB cable into the port on the left-hand side of the board. + + + +--- /task --- + +A Raspberry Pi Pico has 40 pins on its board. Pins allow you to connect external components to the Raspberry Pi Pico. + +If you need to know the pin numbers for a Raspberry Pi Pico, you can refer to the following diagram that shows the underneath side of the Raspberry Pi Pico. + + + +The [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path uses jumper wires to connect electronic component directly to the Raspberry Pi Pico, with resistors as needed. + +[[[pin-socket-jumper-wires]]] + + diff --git a/ru-RU/step_3.md b/ru-RU/step_3.md new file mode 100644 index 0000000..8ba2482 --- /dev/null +++ b/ru-RU/step_3.md @@ -0,0 +1,25 @@ +## Install Thonny + +In this step, you will install Thonny or make sure you have the latest version. Then you will connect to a Raspberry Pi Pico and run some simple Python code using the Shell. + +Note: If you are completing this project in a school or other setting with a managed network, then you should make sure that you have the appropriate permissions to mount a USB drive and install software. + +--- task --- + +The Thonny Python editor can be installed on a Linux, Windows or Mac computer. + +[[[thonny-install]]] + +[[[change-theme-thonny]]] + +--- /task --- + +--- task --- + +Open Thonny from your application launcher. It should look something like this: + + + +--- /task --- + + diff --git a/ru-RU/step_4.md b/ru-RU/step_4.md new file mode 100644 index 0000000..6557e83 --- /dev/null +++ b/ru-RU/step_4.md @@ -0,0 +1,67 @@ +## Add the MicroPython firmware + +If you have never used MicroPython on your Raspberry Pi Pico, you will need to add the MicroPython firmware. + +\[[[add-micropython-firmware]]\] \[[[firmware-installation-menu\]]] + +--- task --- + +Look at the text in the bottom right of the Thonny editor. It will show you the version of Python that is being used. + +If it does not say 'MicroPython (Raspberry Pi Pico)' then click on the text and select 'MicroPython (Raspberry Pi Pico)'. + +If you have never used MicroPython on your Raspberry Pi Pico, then Thonny will prompt you to add the MicroPython firmware. Click install. + + + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- +--- +title: There was an error installing the firmware +--- +If you see an error message during install then: ++ disconnect your Raspberry Pi Pico ++ reconnect your Raspberry Pi Pico ++ try installing the firmware again (you might need to press the stop button first) + + + +--- /collapse --- + +--- collapse --- + +--- +title: I don't know if firmware is installed and cannot connect to my Pico +--- + +Make sure your Raspberry Pi Pico is connected to your computer with a microUSB cable. Click on the list in the bottom right of your Thonny window. A popup menu will appear listing the available interpreters. + + + +If you cannot see the Pico in the list (like in the picture), you will need to reconnect your Raspberry Pi Pico while holding the BOOTSEL button to mount it as a storage volume and reinstall the firmware by following the instructions in the collapse above. + +--- /collapse --- + +--- collapse --- + +--- +title: Firmware is installed but I still cannot connect to my Pico +--- + +You may be using the wrong kind of microUSB cable. Your current microUSB cable may be damaged, or designed only to carry power to devices and cannot transfer data. Try swapping your cable if nothing else has worked. + +If your Pico still won't connect after trying all these things, it may *itself* be damaged and unable to connect. + +--- /collapse --- + +You can find further information in the [Raspberry Pi Pico Guide](https://projects.raspberrypi.org/en/projects/introduction-to-the-pico){:target="_blank"}. + +--- /task --- + + +**Tip:** To update to the latest MicroPython firmware, click on 'MicroPython (Raspberry Pi Pico)' at the bottom of the Thonny window and choose 'Configure interpreter...'. Follow the instructions to update MicroPython. \ No newline at end of file diff --git a/ru-RU/step_5.md b/ru-RU/step_5.md new file mode 100644 index 0000000..ffac198 --- /dev/null +++ b/ru-RU/step_5.md @@ -0,0 +1,38 @@ +## Install the picozero library + +`picozero` is a MicroPython library for beginners to the Raspberry Pi Pico. + +--- task --- + +To complete the projects in this path, you will need to install the picozero library as a Thonny package. + +In Thonny, choose 'Tools > Manage packages...'. + + + +--- /task --- + +--- task --- + +In the pop-up 'Manage packages for Raspberry Pi Pico' window, type `picozero` and click 'Search on PyPi'. + + + +--- /task --- + +--- task --- + +Click on 'picozero' in the search results. + +Click on 'Install'. + + + +When installation has completed, close the package window then exit and reopen Thonny. + +--- /task --- + +If you have difficulties installing the `picozero` library in Thonny, you can download the library file and save it to your Raspberry Pi Pico. + +[[[picozero-offline-install]]] + diff --git a/ru-RU/step_6.md b/ru-RU/step_6.md new file mode 100644 index 0000000..839e2df --- /dev/null +++ b/ru-RU/step_6.md @@ -0,0 +1,157 @@ +## Write a program + +In this step, you will run some simple Python code on your Raspberry Pi Pico. + +### Use the Thonny Shell + +--- task --- + +Make sure that your Raspberry Pi Pico is connected to your computer and you have selected the MicroPython (Raspberry Pi Pico) interpreter. + +--- /task --- + +--- task --- + +Look at the Shell panel at the bottom of the Thonny editor. + +You should see something like this: + + + +--- /task --- + +--- task --- + +Look at your Raspberry Pi Pico and find the small LED next to the USB connector. + +{:width="200px"} + +--- /task --- + +--- task --- + +Create a new file in Thonny by clicking 'File > New' in the top menu bar. An empty workspace should open. + +--- /task --- + +--- task --- + +Type the following code into the main editor pane in Thonny: + +--- code --- +--- +language: python filename: line_numbers: false line_number_start: +line_highlights: +--- +from picozero import pico_led + +pico_led.on() + +--- /code --- + +--- /task --- + +--- task --- + +Choose 'File->Save As'. Thonny will ask whether you want to save the file on **This computer** or the **Raspberry Pi Pico**. Choose **This computer** to save your code to your computer. + +Choose a location on your computer such as your 'Documents' folder. Name your file 'pico_led.py'. + + + +--- /task --- + +--- task --- + +**Test:** Thonny has a green play button with a small white triangle inside it. Pressing this button allows you to run your code. + ++ Press the play button. + ++ Check that the small LED on the Raspberry Pi Pico turns on. + +{:width="300px"} + +--- /task --- + +--- task --- + +**Debug:** + +--- collapse --- + +--- +title: The play button is faded out +--- + +If you don't see a green play button (it is faded): ++ click the red 'STOP' button ++ check that your Raspberry Pi Pico is connected to your computer with a USB cable ++ click on 'MicroPython (Raspberry Pi Pico)' at the bottom right of Thonny to reconnect ++ unplug your USB cable and then plug it back in + +--- /collapse --- + +--- collapse --- + +--- +title: Thonny says that there is an error in my code +--- + +Check your code very carefully and make sure it matches the example. + +--- /collapse --- + +--- collapse --- + +--- +title: There are no errors in my code but the light doesn't come on +--- + +Try a different USB cable, making sure that it is a **data** USB cable. As a last resort, try another Raspberry Pi Pico (if you have a spare). + +--- /collapse --- + +--- /task --- + +The LED will stay on until you write code to turn it off or you unplug the Raspberry Pi Pico. + +--- task --- + +Import `sleep` to allow you to pause your code. Add code to the end of your script to sleep for one second and then turn the LED off. + +--- code --- +--- +language: python filename: pico_led.py line_numbers: true line_number_start: 1 +line_highlights: 2,5-6 +--- +from picozero import pico_led from time import sleep + +pico_led.on() sleep(1) pico_led.off() --- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the green play button. Thonny will save the file on your Raspberry Pi Pico and then run the new code. + +Check that the LED turns on and then goes off again. The LED will only light for one second so make sure you are watching. + +Run your code as many times as you like. + +{:width="300px"} + +**Debug:** + +--- collapse --- + +--- +title: Thonny says sleep isn't defined +--- + +Add the `from time import sleep` line. + +--- /collapse --- + +--- /task --- + +You are now ready to start the [Introduction to Raspberry Pi Pico](https://projects.raspberrypi.org/en/pathways/pico-intro) path. \ No newline at end of file diff --git a/ru-RU/step_7.md b/ru-RU/step_7.md new file mode 100644 index 0000000..3bfd170 --- /dev/null +++ b/ru-RU/step_7.md @@ -0,0 +1,17 @@ +## Resistors + +Resistors are used in circuits to reduce the flow of electrical current. Certain components, such as LEDs, can break or have a reduced lifetime if too much current flows through them. + +When using LEDs with a Raspberry Pi Pico, you should use a resistor of around 100Ω (say Ohms). Any resistor from 75Ω-220Ω will work. + + + +Red Red Brown = 2 2 1 = 2 2 x 10 = 220Ω + + + + +Violet Green Black = 7 5 1 = 7 5 x 1 = 75Ω + +[[[generic-physical-resistors]]] + diff --git a/ru-RU/step_8.md b/ru-RU/step_8.md new file mode 100644 index 0000000..4d0e207 --- /dev/null +++ b/ru-RU/step_8.md @@ -0,0 +1,109 @@ +## LEDs + +Light Emitting Diodes (LEDs) produce light when an electric current is passed through them. + +You can get many different colours of LEDs. + +