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

Try changing both of the time.sleep values to different numbers and see what happens. It should change the speed of the flashing LEDs.

Great job makers, you’ve now got the skills to use physical inputs with MicroPython ( which will come in handy for the rest of the calendar) and can code if statements in all sorts of interesting new ways! 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. The readings from the potentiometer are between 0 and 65535, and our buzzer duty (volume) uses the same range, so we can use the potentiometer readings to directly control the duty - handy! This is because GPIO pins with no pull down (or pull up) can be ' floating' between 0V and 3.3V - ' pulling down' the pin to 0V ensures it's always LOW to start with. 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.

Today’s Projects

The holes in the middle are connected in vertical lanes, with each lane having 5 connected pins either side of the divider. The divider stops both sides connecting together. The Circuit days of blinky projects using the included Raspberry Pi Pico H, with new components to play with every day! Our code imports pinagain, and also imports time. We then define the pin number for each colour of LED (giving them a sensible name for each) and set them to outputs. 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. 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.

We're using Windows (11) in the example projects using the Thonny IDE. Thonny is also available for MAC and Linux machines and there should be very little difference from the instructions. Chromebooks are not supported. Now to add your motion sensor. Just to note, the diagrams below also use a generic motion sensor part from Fritzing as there is currently no part for the mini version in your box. The wiring is the same. Let it Glow is our brand new 12-day Maker Advent Calendar dedicated to all things blinky - things that light up, flash, illuminate All we're doing here is taking our target score, dividing it by 100 to give us 1%, then multiplying that by whatever percentage of score completion we want each LED to light at - and then compare that to the players score.

The Ideal Festive Treat

The example below includes the same ingredients you're now becoming familiar with - imports, pin setup (with PWM), PWM duty cycle and frequency - so there's nothing new or scary here, and our usual slightly-excessive code commentary tells you what each line is doing! Now, get some rest and a good night’s sleep, for tomorrow we will continue the fun with day #2 (no spoilers here, and no peeking until the morning!).

We used a variableto make a counter in day #2 which we constantly updated. This time we're using a variable to allow us to set a value in one place rather than having to search through our code for all the various time delays. These breadboards have two sets of horizontal channels (red/blue) on both sides. All the red pins are connected, as are the blue (but each side is disconnected from the other). We use these to create 'rails' of connections for us to use, such as Ground (GND) for the blue channel and 3.3V for the red. Thonny is a Python IDE. An IDE is an Integrated Development Environment. IDEs help us to write code by giving us lots of helpful features to avoid errors, make our code more readable and lots of other benefits. The program for this is very similar, however we change the LED control section to turn each LED on one by one, turning off the others as we go.

Activity 5: Festive Jingle using Functions

This initial simple code uses just the first button. The code includes our usual imports and pin setup, then starts a while loop. The while loop contains an if statement that looks for a HIGHsignal ( 1) on GPIO 13. Like our larger breadboard, that central channel disconnects one side from the other, which is handy when wiring projects otherwise all of our button legs would be connected together ( and we really don't want any magic blue smoke!).

Until now, we've been using digital signals with the buttons and LEDs in our calendar. Digital signals are strictly a 1 or a 0, HIGH or LOW, ON or OFF. It's one or the other and nothing in between. This leaves plenty of time for customers to receive their calendars in time for the 1st December start date.

For your team - We think this will be a great gift for your teams of techies! Before long you'll have flashing lights and other festive fun projects all over the office! Below is an example of a simple function that prints 3 lines. We create a function by writing ' def' followed by a space and then the name we want to give our function (no spaces in the function name) . Copy it over to Thonny and give it a whirl. We find that if you sit perfectly still, then wave your hands around, you should be able to test the program without having to leave the room! # Imports

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