Introduction to Raspberry Pi through Making
Objectives
The students will be able to:
- Use an if statement to control flow in a Python program
- Use an if-else statement to control flow in a Python program
- Create a flow-chart diagraming the logic of their program
Lesson Outline
- Discuss students thoughts on how to make an LED light up if the temp is too high
- Review an example of an if statement as a class
- Students build temp sensor with one LED
- Review an example of an if-else · Students build temp sensor with two or more LEDs
- Students brainstorm for final project · Journal Reflection
Teaching/Learning Activities
- Guide a discussion on students’ thoughts about the challenge proposed at the end of last session.
- It is important to gauge your own classroom. If some student voices are not being heard equally it may be useful to use a think-pair-share or cold calling.
- Students will likely come to the conclusion that they need a way to ask IF the temperature is a specific number. Guide students to this conclusion if necessary.
- Tell students you have some code for them to investigate.
- Project the file if_example.py (see resources) and ask students to guess what will happen. Emphasize that this is something they haven’t seen before so there’s no wrong answer, just a guess.
- Eventually draw a flow chart to demonstrate a way to visualize this code
- Make sure to point out the syntax of an if statement
- if <true/false statement> :
- followed by an indented block that will be executed if the statement is TRUE
- Have students use their skills to create an LED that lights up if a temp is above a specific cutoff.
- As students get this working encourage them to think about improving their device.
- They will likely realize that they want to have a second light for if the temp is below the cutoff
- Give them the example file if_else_example.py (see resources)
- Push students to continue the Think-Make-Improve cycle. Guide them to wanting to build something that has 3 lights, one for too cold, one for a range that is just right, one for too hot. Allow students to struggle on their own to figure out how to create a range. You can give them the example file if_range_example.py if necessary.
- Display problem statement for final project (MODIFY AS WORKS FOR YOUR SETTING)
- How can we use the raspberry pi to make an average day at school better?
- Facilitate a discussion of what “better” means in this context.
- Present the evaluation criteria, is the project:
- Beautiful
- Thoughtful
- Personally meaningful
- Sophisticated
- Shareable with respect to an audience
- Moving
- Enduring
- Give students time to think individually.
- Journal reflection:
- Why are you working on this final project? What makes it so interesting/exciting that you want to spend the next two days working on this?
- What is a challenge you’ve run into while working so far in this course?
- What is something you’re proud of from your work today?
- It’s important you actually read their answers and use this information to encourage and build a strong relationship.
NOTE: It is important as the teacher to carefully read the support your students need and provide the least amount possible. It is okay for them to struggle on this for a while, and much more rewarding for them to discover how this works on their own. The skill of being able to transfer what is happening in the examples to another context is essential in computer science and should be encouraged. If your students seem able, it could be cool to have them do some research on the internet as opposed to giving examples so they feel empowered to figure out future problems on without teacher support.