276°
Posted 20 hours ago

MAKERFACTORY 15045 Advent Calendar for Raspberry Pi

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

About this deal

The Pico comes with a little LED onboard, which is attached to one of the Pico’s RP2040 pins, GPIO25. This pin isn't one of the physical pins available around the edge of the board. We'll be using the light sensor from box #6 in our examples today, so we need to wire that up as well. We'll use our mini breadboard for this.

We need to ensure players can't cheat by simply holding their finger in place, so we'll use the same method as yesterday's counting code where we demand the pin status to change before the code will accept another count. We'll also add our buzzer to the code to add beeps for the game start/finish. We use jfor colours and i for the LED range - if you remember from previous boxes, it doesn't matter what we use here. We could use ' colour' instead of ' j' and ' led' instead of ' i'. There are no rules here, just traditions! When to Write Data

Activity 2: Using Multiple LEDS

These strips can show lots of different colours as they are RGBstrips - let's cover that first. What is RGB? We know we can grab a single reading from the sensor with a very short program, but we really need that reading to be in a format that we can use and recognise.

Oh and a comment on day 12, besides it been a well explained intro to using RGB LEDs and some concepts in MicroPython, you did describe len and getting the length of a list, but never actually say that len is a function :). Let's go one step further, adding more lines and changing the position of the text, but first let's cover those arguments... Arguments Have a good look through the code example, then copy it over to Thonny to try it for yourself: # ImportsYou can of course be greedy and have both calendars, but there will be a little overlap between them (mostly the first few days as we introduce the Pico and some of the basics) FAQ I2C requires just two wires to communicate (along with 3.3V and GND for our display) and has benefits over some other communication options - but we won't bore you with that just now as it's not going to be relevant until you're much further along on your maker journey. Tip: If we didn't divide the sensor reading, we would be sending values from 0 to 65535 to our time delay (as seconds), which would be far too slow for the effect we're looking for. Place the three LEDs into the lower section of the breadboard, 1 hole apart, with the longest leg to the right as seen in the image below.

Now, whilst we could just straight into something flashy and colourful with all the bells and whistles, we want to guide you through some easy examples first so you can understand how the code works. Whilst only teeny-tiny, these little displays are great for showing data from your project such as sensor readings, scores, pin status, alerts and other useful information. We're going to combine it with some components from earlier boxes to show you just how handy these are. Now try changing the 1 to a 0 - run the code again and it should turn the LED off. You can also try adding a print line at the bottom to show a message at the same time. Day #1 Complete! elif (targetscore/ 100 * 33) < scorecounter < (targetscore / 100 * 66): # If our score is between 33% and 66% of the target This was a little longer than some of our other days as these LED strips are such a fun and versatile part to play with (and there's so much more you can do!).Good job makers! We've learnt how to use another sensor today, as well as introducing some new ways to manipulate values and strings. Here's my plan. I am tired of shop-bought junk at Christmas and also my kids opening all the advent calender doors by the 2nd December. I know its August but I think Ill need 4 months to get this to work as I am a complete beginner to Python, Pi and anything clever.

To light more of our LEDs, we need to tell MicroPython which LEDs we want to send data to. So far we've only told MicroPython to light up LED 0 (the first LED). A Basic Method Our GPIO pins (the green ones from the pin map) can be set as inputs or outputs. We use inputs when we want something to send signals/voltage in to the Pico, like a button or a sensor , and we use outputs when we want the Pico to send signals/voltage out to something else, like LEDs or buzzers.

Our final example adds the % symbol after the reading. We do this by adding some parts to our print line. Please do not disassemble the circuit as we're going to be using it again with the contents in the next box...see you all tomorrow! Let's start with a minimal program to take a single temperature reading from the sensor. Library imports It doesn't matter which side of the LED the resistor sits , as long as it's there limiting the flow of current for the entire circuit ( take a look at the comment section for an example ). Raspberry Pi Pico Pin Map

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