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

If the button is pressed and a signal is sent to that pin, our code will print " button 1 pressed".

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 blinky and something to control your light-up components - think sensors, sliders and more... 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.

Keep your circuit safe somewhere until tomorrow ( don't take anything apart just yet). See you then!

Nice and simple code here that you've played with before - we importwhat we need, set up the break beam pin number (with pull down), then run a while loop with an if statementwaiting for the pin to go LOW(the beam to be broken).Now fit your PIR to the top of the mini breadboard in the orientation shown in the image above (with the 3.3V pin to the left) as shown below: Place a resistor between the left leg of each LED and the lower blue channel, like below. We'll be connecting that blue channel to a Ground (-) pin shortly. If statements can be very powerful and there are lots of different and advanced ways to use them. You'll use them lots when making your own code. We'll start with a nice simple example, but first let's explain something else new in our code - pull downs. Pull downs The example below is purposely inefficient and uses a LOT of lines, mostly because each section of the jingle includes lines to turn the volume on then off as well as delays. Try this first, then we'll move on to a nicer way of doing things in the next activity.

reading = potentiometer.read_u16() # Read the potentiometer value and set this as our reading variable value We're going to be adding components to our breadboard. Breadboards allow you to connect and prototype a circuit without soldering, using wires with pins at the end called jumper wires ( sometimes called DuPont wires). You now have another sensor in your ever-growing box of bits to make projects with - perhaps you'll combine it with the PIR sensor from day #7 to make an awesome alarm with multiple sensors? Today we’ll be programming the buttons in your box as inputs for our code. Whilst we can easily use code to trigger our program to 'do things' (such as counting), components like buttons and switches allow us to physically interact with our project. Try changing both of the time.sleep values to different numbers and see what happens. It should change the speed of the flashing LEDs.That last activity included a lot of detail so we're going to leave it there for today and not overload your fresh coder brains! Now remove the light sensor parts from yesterday, leaving the LEDs and buzzer in place with the Pico on the main breadboard. Your circuit should look like this to start with: We wanted the calendar to be a non-scary, gentle introduction to coding and electronics, which we hope lays the foundations to make people want to go off into the wild after day 12 and start finding new ways to use Python, new components, new project examples and crucially, more detailed information on electronics and how things work. The else statement says " if none of the statements above have their conditions met, do this instead". It can be useful if you want something to always happen when none of the above if/elif statements are being met.

We have included a 50/50 split between blinky components and control components (we alternate each day)Whilst there are more advanced ways of achieving this ( using lists for example which we'll cover in a future box), we’re going to keep things simple whilst we continue to learn MicroPython. Grab your potentiometer, slide the flat washer over the dial and then screw on the included nut (these may already be fitted). 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!

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