276°
Posted 20 hours ago

FRANZIS 55103 Raspberry Pi Advent Calendar, Build and Program a Nativity Scene in 24 Days, Includes 52 Page Manual, No Soldering

£9.9£99Clearance
ZTS2023's avatar
Shared by
ZTS2023
Joined in 2023
82
63

About this deal

We also don't want you forgetting how to make functions ( which we covered on day #5 with the buzzer), so you'll notice that we've made a function called alarm() which we callwhenever we want to trigger the LEDs and buzzer. A function wasn't strictly necessary here, but it's good practice! Try this yourself, then try adding a fourth argument and printing a fourth line to go with it. The Code It might not look like much in this example, however in large projects this can save a LOT of lines in your code. It also makes it a lot easier to update your code as you only have to amend the one function - not every part of your program. The right pin needs to connect to the 3V3(OUT) pin ( physical pin 36), the middle pin to GPIO 27 ( physical pin 32) and the left pin to GND (use the blue lane as we already have that connected to GND for the LEDs). An LED is a Light Emitting Diode. These components emit light when electrical current flows through them.

You’ll now be presented with some options in a new dialogue box. Use the same options as per the screenshot below, selecting the RPI-RP2 target volume, Raspberry Pi Pico / Pico H variant, and whatever the latest version is available ( at the time of writing it was 1.19.1): For new coders - The included Pico H and project parts, combined with the easy-to-follow instructions, clear example code and helpful wiring diagrams make this perfect for anyone wanting to get started with the Raspberry Pi Pico, programming and electronics. The blinky theme keeps it fun and festive too! We can also use the wide range of analogue values to trigger an action depending on where abouts in the overall range we are. We can do this by using if statements again, this time with conditions that look to see if the value is higher, lower or between a set range! We include a short delay in this loop to give your finger a chance to release the button, to avoid the code triggering many times from a single press (known as ' debouncing'). Values of 0.1 or 0.2 seconds usually work well. Here's another simple example just to show you how easy it is to change the tone on your buzzer from one to another.

This is the last time we'll be using the LEDs in the calendar, so go ahead and remove them from your circuit (it's best to keep them in the same bag as the resistors so that you don't mix them up). We also won't be using the buzzer tomorrow, so you can remove that as well. Something different you'll spot next is where we wait for the sensor to settle or 'warm up' before jumping into our while loop. Warm Up This is a digital sensor, giving us a HIGH signal if movement is detected. We can code this in a similar way to the buttons from day #3 as a trigger for our program. The time module allows you to program delays in your code, making it wait for seconds or fractions of seconds before continuing. It’s another fundamental module you’ll use in most of your projects. The Code

The Pico can use many different programming languages, however the most popular is MicroPython which is what we'll be using over the next 12 days.You’ll receive a different project component every day including any required wires/resistors/accessories You then need to connect the red 3.3V lane to one side of each of the buttons, go for the right side like we have below: We also import sysin this example. The only reason we add this is to allow us to use sys.exit() to end the program after the game has finished. In the example below, in each while loop we take a reading from the potentiometer and store it in a variable called 'reading' (just like we did yesterday in activity 3) and then we use this variable as the buzzer duty value (instead of adding a number there ourselves).

We’re going to install software called Thonny, which will allow us to program the Pico with MicroPython. As always, please do not disassemble the circuit until tomorrow where we will explore the next fun component - see you then! The while True loop then reads the potentiometer value and stores this in our readingvariable, and prints this for us to view in Thonny

Activity 3: LED Sequence

Our code below also uses pull downs - you can see this at the end of each of the button set up sections as Pin.PULL_DOWN. The break beam sensor in your box comes with two parts - the emitter (2 wires) and the receiver (3 wires). The emitter sends an infra-red light out which is detected by the receiver, which keeps the white signal pin HIGH. If something breaks this beam ( gets in the way) the receiver does not detect a signal and then sends the pin LOW.

I got the same sort of thing you did with the potentiometer readings at first, I think I just disconnected and re-connected. unplug and plug in again, a lot like working with computers and microcontrollers, turn it off and on again :). Most buttons are very simple, just connecting a circuit together which then sends a signal to our Raspberry Pi Pico via our chosen GPIO pin. You could do the same by simply touching two wires together, but of course buttons make this far more convenient and user friendly.

This is one of the easier components to work with as we've included a custom pre-wired buzzer with male jumper wire ends. The code below imports ADCand sets GPIO27 as an ADCpin, then we start a while loop which prints the potentiometer's value every second. Today we’re going to get you set-up and familiar with the Raspberry Pi Pico, including installing the software required to program the board as well a running a couple of very easy projects to get to grips with MicroPython. Introducing the Raspberry Pi Pico We're specifically using GPIO27 as this is one of the Pico's ADC pins. But what is an ADC? ADC Pins Keep your circuit safe somewhere until tomorrow ( don't take anything apart just yet). See you then!

Asda Great Deal

Free UK shipping. 15 day free returns.
Community Updates
*So you can easily identify outgoing links on our site, we've marked them with an "*" symbol. Links on our site are monetised, but this never affects which deals get posted. Find more info in our FAQs and About Us page.
New Comment