Welcome to the Raspberry Pi Workshop! Here you'll be able to follow along with our series that covers everything you'll need to know to get started with your Raspberry Pi and start making awesome projects. My name is Michael from Core Electronics and I'm an electronics enthusiast with particular interest in embedded electronics. As we progress through the workshops, you'll find helpful material next to each video - these could be code snippets, commands to issue, circuits to build, or links to other resources.
Preface: All source code, images and other things we couldn't fit on Udemy can be found here (totally FREE):
In Chapter 1 we are going to discuss what a Raspberry Pi actually is and why it's taken the maker community by storm. We'll walk through going from a fresh-out-of-the-box Raspberry Pi, to installing an OS, booting it up and having a bit of a play around.
By the end of this chapter you will be able to use your Raspberry Pi as a desktop computer. We will have covered:
In this section we're going to discuss what a Raspberry Pi is, the different models that are available and their qualities.
There have been several generations of Raspberry Pi since they were first released in 2012. We recommend the most recent "large-footprint" model, the Raspberry Pi 3 because we think it's the best learning platform; It runs fast and has plenty of connectivity options.
NOOBS stands for New Out Of the Box Software. NOOBS is an operating system installer package put together by the Raspberry Pi Foundation. It comes with one OS already installed and gives the option of downloading several operating systems - convenient for first-time users who want to test-drive their Pi.
You can download NOOBS from the Raspberry Pi Foundation.
We're powering up our Pi for the first time. Let's have a look around and set a few things up. This includes setting up the keyboard and WiFi, exploring the Pi's menus and capabilities, and having a look at some tools we'll use for programming.
If you want to install an OS other than Raspbian using NOOBS you will need to have your Raspberry Pi connected to the internet via its ethernet port. With this connection you will see other options available for download and install.
To power-off your Pi, you can either find the shutdown option in the Pi menu, or issue this command in the terminal:
sudo shutdown -h now
The power light will remain on, to indicate power is connected, but the activity light will remain off.
Try to never remove power from your Pi without doing either of these things first; An unexpected loss of power may corrupt your SD card.
In this chapter you'll learn about:
The Python Standard Library - Useful for a syntax reference and just to explore what pre-built functions are available to you.
The IDLE is Python's shell. It's useful for trying out commands real-time. We can write a Python script, which is just a sequence of Python commands.
I've tried to squeeze in as many Python features as I could into this short script. Compare the script to what you see output when it is run; There's definitely a few tricks worth knowing!
Code for this section:
Challenge: change the for loop that counts in twos to count from -5 to 25 in steps of 5. Remember that you have the Standard Python Library Documentation available, try searching for range.
GPIO or General Purpose Input and Output is the interface that allows your Raspberry Pi to connect to the world. The pins can drive a voltage, sink current, and read voltage levels. Complex digital communications can also take place on the GPIO.
Before we begin, a word about connecting to the GPIO: The pins in the GPIO header are connected directly to the Broadcom processor that is the heart of a Raspberry Pi. You should never prototype circuits while your Raspberry Pi is powered, because a short circuit - no matter how brief - might immediately fry your Pi.
Safely shutdown your Pi as described in Section 1.3 before removing power - then you're ready to prototype some circuits!
We're going to animate a nice sine wave in our shell. To do this we'll write a simple function.
Code for this section:
# Display a pretty sine wave in the Python Shell import math # For the Sine function import time # For sleep() delay numCycle = 5 # Number of times we want our sinewave to cycle pi = math.pi # Less typing required later = more readable code # Function to simplify calling the sine function def sin(x): return math.sin(x) x = 0 while x < (2 * pi * numCycle): bar = int(20*sin(x)) # An integer number for the length of our bargraph x += 0.3 # the same as saying x = x+0.3 print ((21+bar)*"=") # Print the bargraph time.sleep(0.03)
We'll be reusing the LED-button setup from Section 2.2 for this section.
Code for this section is attached.
The RPi.GPIO documentation also has an example which brightens/dims an LED. To acheive that end the example uses some for loops. We encourage you to check that out to see how they did it. Make sure you remember to change the GPIO pin number in the code to whichever one you're using!
In this chapter you'll learn about:
Arguments are pieces of information that we pass in to a program or function. When you issue a command like cd /home/pi, here the command is cd and there is one argument,/home/pi.
In BASH, arguments are accessed in the order they were passed in with $x, where x is the argument number. This means that $1 refers to the first argument, and $4 refers to the 4th argument (if there is one). The name of the command issued is $0.
We're going to write a useful archiving script now. This script will take whatever directory or file we give it, and copy it to a predetermined archive-directory.
We're going to whip-up a very simple GUI to toggle a GPIO pin with. This will familiarise us with the Tkinter workflow:
Here's the gpiozero documentation if you think you'll prefer using it instead of RPi.GPIO.
We've covered several topics throughout this workshop series, and we've really only scratched the surface of each. By now we've assembled a toolbox of useful skills and are aware of the kinds of tasks our Pi can handle.
Where to find inspiration:
Where to get help:
I'm Graham - the founder of Core Electronics. I have been learning, educating and making for over 15 years. Twelve of those were as an Avionics Technician in the Royal Australian Air Force, maintaining fighter jets and in deeper level maintenance workshops. A technically demanding job with broad exposure to many facets of electronics, which led to mentoring and educating others as a senior technician.
During that time (in 2007) I founded "Core Electronics" in Australia which has evolved to become a leading retailer for maker electronics and educational resource for tens of thousands of makers.
In 2016 we launched "Knowledge Factory" in Newcastle (Australia) - a space where we hold free community workshops to walk people over the hurdles with maker tech such as Arduino, 3D Printing and Raspberry Pi. Wonderful!
At every leg of my journey, I've been compelled to learn new skills and help others with their projects. We're now on Udemy and we look forward to helping so many others around the world.