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

You'll notice there are some arguments ( 0,0) after the text we push to the display: display.text("Hello World!",0,0) Temperature sensors are another component that you'll likely walk past every single day. The thermostat for your home's heating system, whether a traditional version or a modern smart thermostat, will use something similar to what you find in your box today. Ovens, cars, offices and many other everyday items and locations use temperature sensors. The second line is setting up one of the pins to allow us to use it in our code. This sets up GPIO25 with the name ‘ onboardLED’. We use Pin.OUT at the end there to tell MicroPython to set this pin as an output.

Our final example adds the % symbol after the reading. We do this by adding some parts to our print line. Welcome to day eight of your 12 Projects of Codemas Advent Calendar. Today we’re going to be sensing the temperature of our local environment and using these temperature readings to make fun projects! These work well when placed up to 20-25cm apart, but they can be a little unreliable outside of that range. More advanced/industrial versions are used for larger areas such as doorways. We then use a while loop which contains a for loop. We used a for loop yesterday with the motion sensor when using the range function, but this time our range will be roms (the number of roms our scan found, which will just be our single sensor). The for loop is saying " for every rom I find, do this".indexlength - this counts the number of items in our colour list (3, in our example). However, as we're using this to identify the last number in our index, we have to -1 at the end (because there are 3 items in our list, but as these will be indexed as 0,1 and 2, we want our maximum index value to be 2) We've covered while loops, if statements, if/elif and ranges in the previous boxes, so the code in this example should feel very familiar. We then need to set up I2C and the display which you'll see on line 7. This includes the GPIO pins we're using ( GPIO0and GPIO1) which are the SDA and SCL pins, used for I2C connections. After this line we always have to wait around 1 second otherwise I2C can get all stroppy and fall over! Try the code below, then try playing with the colour values - try using iin other places such as strip.fill((i,0,i)) or add fixed values to the other colours such as strip.fill((i,0,50)): # Imports My previous comment had an error as I removed an unneeded variable but left in a reference of it, remove the comment if you want! I’ve cleaned it up more and put in some explanation comments in the code for the bits I added or changed.

We'll cover what the the 0,0 arguments do in the next activity, but for now, c opy this over to Thonny and see it for yourself! # ImportsAnother day, another component completed! You now have a temperature sensor in your growing arsenal of parts to make projects with, and we're sure you'll use this one time and time again. No. We include the Pico H which is the non-WiFi version, which helps keep the cost down and is ideal as your first Pico board. It's otherwise quite straightforward, adding +1 to our counter at the end of every loop to continually increase it. You can play with the time delay within the while loop to see just how fast it can run: # Imports Each item in a list is given an index. This means that each item in a list is given a number, starting from zero. To set the LED strip up, line 7 sets the pin number for the strip ( GPIO28) and the number of LEDs on the strip ( 15). We can now refer to it using ' strip' in our code.

We've used variables a lot over the last twelve days, so you might already know what to do here but we're going to show you just in case! It's a type of digital display technology that uses LEDs and layers of thin organic film between two electrodes. When electrical current is applied, the display emits light. Our code tells the display where to show light and when. What is I2C? There are a few new elements in the example code that we need to introduce, so let's go over them first... Time and EpochFirst, make sure your Pico is disconnected from the USB cable. You should always do this when amending a circuit. Then grab the set of jumper wires, resistors and LEDs. Breadboards You're probably thinking "but we could just use strip.fill((green)) ". This is true, however as the index uses a number, it allows us to easily change that number (and therefore the colour) with our button using variables. 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. We then start a while loop which takes a reading from the sensor on line 25. Now, this line does a lot of things at once so let's break it down:

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