Programmierbeispiele in Python für den PiHut Maker Kalender
Go to file
2023-12-12 23:13:29 +00:00
images Moved Picture in subfolder 2023-12-02 12:51:06 +00:00
pdf Moved PDF 2023-12-05 16:35:09 +00:00
2-dezember.py First Initial 2023-12-02 12:03:13 +00:00
3-dezember.py Day 3 Script added 2023-12-03 10:50:05 +00:00
4-dezember-led-blinken.py Added 4 December Scripts 2023-12-04 18:00:57 +00:00
4-dezember-led-regelung.py Added 4 December Scripts 2023-12-04 18:00:57 +00:00
5-dezember.py Added 5 December 2023-12-05 16:27:53 +00:00
6-dezember.py Added 6-te December 2023-12-06 21:28:00 +00:00
7-dezember.py Added Day #7 and edit Readme 2023-12-07 15:40:12 +00:00
8-dezember.py Added Day #8 and edit Readme 2023-12-08 21:00:44 +00:00
9-dezember.py Added Day #9 and edit Readme 2023-12-09 21:46:10 +00:00
10-dezember-leds.py Added new december files and edit Readme 2023-12-12 23:13:29 +00:00
10-dezember.py Added new december files and edit Readme 2023-12-12 23:13:29 +00:00
11-dezember.py Added new december files and edit Readme 2023-12-12 23:13:29 +00:00
12-dezember.py Added new december files and edit Readme 2023-12-12 23:13:29 +00:00
README.md Added new december files and edit Readme 2023-12-12 23:13:29 +00:00

Day 2 Complete!

Another great day of learning how to code with the Raspberry Pi Pico and MicroPython! Today you have:

Created your first circuit!
Learnt how to use the time module to add delays to programs
Learnt how to use while loops and conditions
Learnt about variables (our counter)
Learnt about code commentary
Created a dashing, flashing sequence of LEDs

Day 3 Complete!

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!

Today you have learnt:

How to create a circuit with physical inputs
How to code physical inputs with MicroPython
What if statements are and how to use them
How to use elif and else within if statements
How to use 'and and 'or' within if statement conditions
Combined physical inputs with physical outputs

Day 4 Complete!

Well done makers! We know today was a little heavier as we introduced slightly more advanced topics such as analogue and PWM, so take the time to go back over today's examples and play with the code if you'd like more practice - make it, break it, fix it, learn!

Today you have:

Learnt about analogue and the difference between analogue and digital signals
Built a circuit with a potentiometer
Leant how to use the ADC built into the Raspberry Pi Pico
Controlled LEDs with an analogue signal
Learnt about PWM including duty cycle and frequency

Day 5 Complete!

We've covered lots today fellow makers, pat yourselves on the back!

As we cover more advanced topics such as functions, you may find that you need to refer back to these days to refresh your memory later on - and that's absolutely normal! Even the most seasoned professional programmers have to use search engines regularly (some even admit it!).

So what did we cover on day #5? Today you have:

Built a circuit with a buzzer, your first audio component
Learnt how to use the buzzer with MicroPython and the Pico
Learnt about PWM frequencies and duty cycle with buzzers
Used analogue inputs to control audio volume using PWM
Created a festive jingle with MicroPython
Learnt how to use functions to make your code easier to manage and more efficient

Day 6 Complete!

Good job makers! We've learnt how to use another sensor today, as well as introducing some new ways to manipulate values and strings.

We're going to use this sensor again before the end of the calendar as it's a great partner for a component hiding in one of the other boxes...

So, what did we learn today? Today we:

Learnt how to wire a light sensor circuit
Learnt how to manipulate data to make it more useful to us and our programs
Learnt how to convert values to strings with the str function
Learnt how use the round function to limit decimal places
Learnt how to combine multiple strings in prints

Day 7 Complete!

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!

The PIR sensor can be so much fun to use and they come in all different shapes and sizes too, you'll be making your own home security system in no time.

So what did we cover on day #7? Today you have:

Built a circuit with a PIR sensor
Learnt how to use a PIR sensor with MicroPython and the Pico
Created a mini alarm system!
Learnt about the range function
Revisited functions

Day 8 Complete!

Another 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.

As you're probably starting to realise, a lot of these sensors and components are coded in a very similar way. Sometimes we need the help of imported libraries, sometimes we need resistors/additional hardware, but the fundamental way we write code for them (with loops, if statements and variables) is pretty consistent.

So what did we cover on day #8? Today you have:

Built a circuit with a temperature sensor
Learnt how to use a temperature sensor with MicroPython and the Pico
Used your first 1-wire component and the 1-wire library
Created a temperature monitor and temperature alarm system
Learnt more about for loops

Day 9 Complete!

Well done makers, we've cracked another sensor. Today's sensor (some might call it a switch) was a little easier than others, especially as you're now so familiar with MicroPython and the approaches we're taking, but we thought a little breather would be good before we adventure on to the fun yet slightly-more-advanced goodies in the final three boxes!

Today you have:

Learnt what a tilt sensor/switch is and why you might use one
Learnt how to wire a tilt sensor into your circuit (easy peasy!)
How to use variables and if statements in a way that improves the robustness and accuracy of our project
Made a basic tilt alarm
Re-used lots of things you've already learnt!

Day 10 Complete!

We hope you enjoyed the games in today's break beam activities - why not get the whole family involved to show off your project and see who can score the highest for ultimate bragging rights?

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?

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.

So what did we cover on day 10? Today you have:

Built a circuit with break beam sensors
Learnt how to code break beams sensors (with their 'always HIGH' way of working)
Created a fun break beam game
Learnt additional time module options, including epoch time
Learnt how to use the sys module to end a program
Created nested if statements
Used simple maths to turn values into percentages with MicroPython
Continued to re-use all off the things you've learnt over the last 10 days

Day 11 Complete!

Aren't OLED displays just bags of fun? We've only just scratched the surface as well! There are lots of clever ways you can use these kinds of displays with graphics, fonts and other tricks, but we wanted to keep our activities relatively simple for beginners.

You'll find a ton of resources and other examples on the internet that you can use - we even have our own graphics tutorial which can apply to these displays too (with a few tweaks to the code).

Let's recap, what did we learn on day #11? Today we:

Learnt how to wire an OLED to our Raspberry Pi Pico
Introduced the I2C communication protocol
Leant how to install packages in Thonny
Learnt how to code an I2C OLED display, including:
    How to write text to the display
    How to write multiple lines of text
    How to alter the position of text
    How to display sensor data on OLED displays
    A few little tricks like markers!
Re-used knowledge and components from previous boxes, such as:
    State variables
    Converting integers to strings
    Nested if statements
    Light sensors
    ...and more!

Day 12 Complete!

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!).

We're pretty sure most of you will be turning your strip into a fancy monitor backlight - perhaps some will combine it with the PIR to turn it on when there's motion in front of their PC, or maybe some cleverly hidden break beam sensors will be used as a hand-activated colour changer? Whatever you make, we'd love to hear about your projects in the comments section!

So what did we cover on day #12? Today you have:

Learnt what an addressable LED is and why they're sooo fun!
Built a circuit with addressable LEDs
Learnt about RGB and how to create colours with RGB values (and where to find them)
Learnt how to code addressable LEDs with MicroPython
Learnt different ways to light the entire strip...some more efficient than others!
Created colour variables
Leant how to create and use lists in MicroPython, including list indexes
Used nested for loops
Leant how to use len in MicroPython
Faded addressable LEDs using range (both counting up and down)