SlideShare a Scribd company logo
ulster.ac.uk
Not so hard “hardware”
-Using Raspberry Pi GPIO pins with Scratch
Richard Gault
PhD Researcher in Computational Neuroscience
Intelligent Systems Research Centre
Ulster University, Magee
Not so hard “hardware”
Contents
- Teaching through context and effective use of language
- Evolving an open ended problem
- Using the Raspberry Pi GPIO pins from Scratch
- First Project:
- Belisha Beacon
- Extending knowledge:
- Traffic Lights
- Introducing Inputs:
- Pedestrian Crossing (Pelican Crossing/Toucan Crossing)
- Extending knowledge and introducing sensors:
- Puffin Crossing
Teaching through Context and effective use of language
Benefits of Teaching through Context:
- Bringing learning beyond the classroom
- Encourages deeper thinking in the world around
- Develops thinking from different perspectives
Effective use of Language:
- Closes the gap between problem solving and coding
- Provides a more structured discussion for problem
solving.
- Helps to put students in the computer perspective
Evolving an open ended problem
All aboard ‘computing sight seeing tours’
1
2
3
4
On the tour we will have:
- Raspberry Pi/Scratch/GPIO
- Electronics/Physics/Circuit Diagrams
- Controlling Outputs using Scratch
- Sequences
- Loops: Both finite and infinite
- States and state transition
- Handling inputs using Scratch
- Modifying behaviour to evaluate understanding of concepts
- A brief glimpse at sensors
Getting Started
Main components
- Raspberry Pi (RPi)
(These slides are based on (RPi 1), B+ V1.2)
Setting up the RPi
Also see Chapter 1: Adventures in Raspberry Pi, Carrie Anne Philbin (Wiley
2014)
- Students should have basic experience of using Scratch
RPi 2 Model B
GPIO pins
- General purpose input/output (GPIO) pins can be used to
interact with the real world.
- Using these pins is completely safe, however, you
should take great care when connecting cables to the
GPIO pins on your Raspberry Pi (to protect you and the
device).
Some pins are designated as power
supply (red) and others as ground
(black). The rest can either be for an
input or an output.
Input Output
GPIO Pins
How do they work?
Output:
The RPi acts as both a power supply and a switch. So
when we turn a particular pin on (or set it high, or to 1) in
our code, we are turning on a switch. It will remain on until
we set the pin to be off (or set it low, or 0).
GPIO Pins
How do they work?
Inputs:
Inputs are a little more tricky. For our work, if enough ‘input’
(voltage) comes in then the RPi will register that there is an
input, i.e. Yes = 1, or there isn’t, i.e. No = 0.
Using the GPIO pins from Scratch
You cannot automatically control the GPIO pins from
Scratch.
Option 1: Pi_Scratch(Pridopia)
Option 2: ScratchGPIO
Option 3: ???
If you find other alternatives please share them with the
CAS community!
Getting Started with ScratchGPIO
Select the right version for you:
- For RPi 1, model B+ V1.2, I recommend using
ScratchGPIO5
- For RPi 1 models before B+ you may need to
use an earlier version
- For RPi 2 with Scratch 2.0, I recommend using
ScratchGPIO7
You can download and install the right version for
you either straight from the internet to the RPi or
first downloaded on to a memory stick and
complete installation from the memory stick onto
the RPi.
Word of Caution!
Input and Output pins are pre assigned when
starting up ScratchGPIO – You can change
inputs to outputs (and vice versa) later if
needed.
Pin naming convention ->
pin11on
pin11high
GPIO17on
GPIO17high
Know your pin layout!
RPi 2
also
* You can damage the RPi by plugging components in to
the wrong pins.
Getting started with ScratchGPIO
What’s going on?
Once you have successfully installed ScratchGPIO:
Use ScratchGPIOX …without the ‘plus’
When you open up:
From ScratchGPIO we will broadcast specific messages
that the scratch gpio handler will understand and execute
the appropriate commands.
Stop 1: Belisha Beacon
Zebra Crossing
Lesson based upon road safety and different types of
crossings.
What exactly is a Belisha beacon?
- “It is a flashing light”
- “The light turns on and then off”
- “The light turns on, then after a second or two it turns off”
Recipe for Belisha beacon:
Ingredients will include: A light, RPi
Instructions will include: Turn light on
Wait 1 second
Turn light off
Wait 1 second
Stop 1: Belisha Beacon
Ingredients
Stop 1:Belisha Beacon
Set up: Hardware
Connect the positive side of the LED to a resistor, and
connect the resistor to pin 11 of the RPi. Connect the
negative leg of the LED to any of the ground pins of the
RPi. (see OCR Traffic Lights Recipe)
Without Breadboard With Breadboard
Stop 1: Belisha Beacon
Set up: Software
Start ScratchGPIO5->Go to the control tab->Use the
‘broadcast’ blocks to communicate with GPIO pins
Stop 1: Belisha Beacon
Implementing our recipe
Stop 1: What can we really do?
Also at this stop:
Electronics->flow of electricity->voltage and current
Resistance-> Actually calculating the voltage and current->V=IR calculations
Reading resistor values->Significant figures and multiplication by 10.
1
2
3
4
Continually turn a light on and off…
-Lights on an emergency vehicle
-Notification light
-School warning sign/train crossing
-Road bollard ->Translucent/transparent/opaque materials
-Traffic lights -> more complex sequences
Stop 2: Traffic Lights
The problem
- First work out the traffic light sequence:
- Traffic lights recipe:
Ingredients will include 3 LEDs
(one red, one amber/yellow, one
green) and 3 resistors, jumper
cables to connect RPi to components
4.
1.
2.
3.
Stop 2: Traffic Lights
Set up: Hardware
See OCR traffic light recipe for set up without breadboard
Stop 2: Traffic Lights
Implementing our algorithm
4.
1.
2.
3.
Stop 2: What do we really know?
- At this stage we can still only control outputs (LEDs)
- The traffic lights can be used to assess the degree of
understanding students have on circuits, using GPIO
pins and algorithmic design.
Also at this stop:
-States and state transitions.
-Repeating sequences.
-2 or more traffic lights
1
2
3
4
Stop 3: Pedestrian Crossing
Pelican crossing
Stop 3: Pedestrian Crossing
Introducing inputs
- Now we will introduce a new element to the problem:
input!
- A button will be used to signal to the system there is a
pedestrian ready to cross
- High or low?
- Let us see what happens
when the button is pressed
What does your input do?
Depending on the type of switch/button and the way you
construct your circuit will dictate what your system will do
when the button is pushed.
The state of the pin will either be of value 1, or value 0.
Push
button
Stop 3: Pedestrian crossing
Implementation
Identifying the correct code to modify
We also need red and
green LEDs for the
pedestrians!
pin26
Stop 3: Pedestrian Crossing
Set up: Hardware
Stop 3: Pedestrian
Implementation
pin26 pin26
Stop 3: Pedestrian Crossing
Pelican crossing from the drivers perspective
Stop 3: Pedestrian Crossing
Pelican Crossing-modified sequence
pin26
pin26
Step 3: What do we really know?
Inputs and Outputs
Switch
Button
Microphone
LED
Buzzer
Heater
Speaker
Also at this stop:
-Toucan crossing
- Inputs vs outputs exercise (telephone)
- Pull up and pull down resistor circuits
1
2
3
4
Input
Output
Why not use the button as an input to a Scratch game – 4
buttons to move a character up/down/left/right.
Revisit the emergency vehicle -> start flashing lights with
the push of a button -> introduce sound(?)
Stop 4: Puffin Crossing
Sensors
Stop 4: Puffin Crossing
Introduction to sensors
- Sensors are used to measure physical quantities such as
temperature, light, pressure, sound and movement.
- We will be using a passive infra-red sensor which will
detect a change in motion.
- If there is a change in motion, the internal properties of
the sensor will change and thus the information being
sent to the RPi will be different than before.
- So our sensor will provide information in to our system.
- We need to test our sensor value like we did with the
button.
Stop 4: Puffin Crossing
Testing the PIR sensor
pin26
Stop 4: Puffin Crossing
Implementation (same hardware set up as Pelican crossing)
pin26
pin7
Stop 4: Puffin Crossing
Looking at a problem from different angles
Traffic lights and pedestrian crossings must account for every eventuality
…as do good computer programs.
This often requires you to look at a problem from various perspectives.
Therefore empathy is in an important attribute to develop to become strong
at problem solving and computing.
Useful Links
Components:
5mm LEDs (x20 Red, x20 green, x20 yellow, x20 blue, x20 white): £1.69*
220Ohm Resistor (x 100) : £1.49*
20cm jumper cables (x40): £1.27-£1.98*
Push buttons (x100): £3.85*
Passive IR motion detector: £3.13*
400 point breadboard : £1.79*
Breakout board (RasPIO Pro) : £9.95
Breakout board (GPIO Cobbler+T-Cobbler+Ribbon Cable+breadboard) :
£11.99 *
37 Sensor kit: £34.95*
Cost for one full project: £3.64 + £11.99(optional bread board and breakout
board)
PiStop: (Traffic lights only) £2.10 -£2.95 (depending on quantity)
*Price includes delivery
Useful Links
Websites:
https://www.raspberrypi.org/
http://simplesi.net/scratchgpio/
http://www.ocr.org.uk/Images/129940-recipe-card-traffic-
lights.pdf
http://fritzing.org/home/
https://www.raspberrypi.org/learning/robot-antenna/
http://camjam.me/?page_id=618
Acknowledgements: Ann O’Neill (Stranmillis University
College)
Web:
http://isrc.ulster.ac.uk/rgault/research.html
Email:
gault-r2@email.ulster.ac.uk
CAS:
Richard Gault (email as above)
Thank you for listening!

More Related Content

Similar to Not so hard hardware

IoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdfIoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdf
GVNSK Sravya
 
RaspberryPi_Workshop and Programming with python.
RaspberryPi_Workshop and Programming with python.RaspberryPi_Workshop and Programming with python.
RaspberryPi_Workshop and Programming with python.
gnanithanagula
 
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi [Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
Tomomi Imura
 
NSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and ArduinoNSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and Arduino
Brian Huang
 
Python-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptxPython-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptx
TuynLCh
 
Quiz
QuizQuiz
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdfamrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapalibuildersreviews
 
Week6_ES_External Sensor in Raspi 4.pptx
Week6_ES_External Sensor in Raspi 4.pptxWeek6_ES_External Sensor in Raspi 4.pptx
Week6_ES_External Sensor in Raspi 4.pptx
deffar1
 
Introduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIOIntroduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIO
Kris Findlay
 
Arduino Slides With Neopixels
Arduino Slides With NeopixelsArduino Slides With Neopixels
Arduino Slides With Neopixels
sdcharle
 
Arduino embedded systems and advanced robotics
Arduino embedded systems and advanced roboticsArduino embedded systems and advanced robotics
Arduino embedded systems and advanced robotics
Shubham Bhattacharya
 
Intro to the raspberry pi board
Intro to the raspberry pi boardIntro to the raspberry pi board
Intro to the raspberry pi board
Thierry Gayet
 
#Make01
#Make01#Make01
#Make01
Sandro Salari
 
Advanced View Arduino Projects List - Use Arduino for Projects-5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-5.pdfAdvanced View Arduino Projects List - Use Arduino for Projects-5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-5.pdf
WiseNaeem
 
188933 project instrumentasi smart house
188933 project instrumentasi smart house188933 project instrumentasi smart house
188933 project instrumentasi smart house
amimahsiti
 
project instrumentasi smart house (smart trash bin)
 project instrumentasi smart house (smart trash bin) project instrumentasi smart house (smart trash bin)
project instrumentasi smart house (smart trash bin)
Mimi Chinho
 
Linux Format - Get Into Linux Today
Linux Format - Get Into Linux TodayLinux Format - Get Into Linux Today
Linux Format - Get Into Linux Today
Heart Disk
 
Instrumentasi project smart house (Smart Trashbin)
Instrumentasi project smart house (Smart Trashbin)Instrumentasi project smart house (Smart Trashbin)
Instrumentasi project smart house (Smart Trashbin)
risanads97
 
Introduction to Arduino with ArduBlock & SparkFun LilyPad
Introduction to Arduino with ArduBlock & SparkFun LilyPadIntroduction to Arduino with ArduBlock & SparkFun LilyPad
Introduction to Arduino with ArduBlock & SparkFun LilyPad
Brian Huang
 
Rasperry pi Part 13
Rasperry pi Part 13Rasperry pi Part 13
Rasperry pi Part 13
Techvilla
 

Similar to Not so hard hardware (20)

IoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdfIoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdf
 
RaspberryPi_Workshop and Programming with python.
RaspberryPi_Workshop and Programming with python.RaspberryPi_Workshop and Programming with python.
RaspberryPi_Workshop and Programming with python.
 
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi [Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
 
NSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and ArduinoNSTA 2013 Denver - ArduBlock and Arduino
NSTA 2013 Denver - ArduBlock and Arduino
 
Python-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptxPython-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptx
 
Quiz
QuizQuiz
Quiz
 
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdfamrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
 
Week6_ES_External Sensor in Raspi 4.pptx
Week6_ES_External Sensor in Raspi 4.pptxWeek6_ES_External Sensor in Raspi 4.pptx
Week6_ES_External Sensor in Raspi 4.pptx
 
Introduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIOIntroduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIO
 
Arduino Slides With Neopixels
Arduino Slides With NeopixelsArduino Slides With Neopixels
Arduino Slides With Neopixels
 
Arduino embedded systems and advanced robotics
Arduino embedded systems and advanced roboticsArduino embedded systems and advanced robotics
Arduino embedded systems and advanced robotics
 
Intro to the raspberry pi board
Intro to the raspberry pi boardIntro to the raspberry pi board
Intro to the raspberry pi board
 
#Make01
#Make01#Make01
#Make01
 
Advanced View Arduino Projects List - Use Arduino for Projects-5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-5.pdfAdvanced View Arduino Projects List - Use Arduino for Projects-5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-5.pdf
 
188933 project instrumentasi smart house
188933 project instrumentasi smart house188933 project instrumentasi smart house
188933 project instrumentasi smart house
 
project instrumentasi smart house (smart trash bin)
 project instrumentasi smart house (smart trash bin) project instrumentasi smart house (smart trash bin)
project instrumentasi smart house (smart trash bin)
 
Linux Format - Get Into Linux Today
Linux Format - Get Into Linux TodayLinux Format - Get Into Linux Today
Linux Format - Get Into Linux Today
 
Instrumentasi project smart house (Smart Trashbin)
Instrumentasi project smart house (Smart Trashbin)Instrumentasi project smart house (Smart Trashbin)
Instrumentasi project smart house (Smart Trashbin)
 
Introduction to Arduino with ArduBlock & SparkFun LilyPad
Introduction to Arduino with ArduBlock & SparkFun LilyPadIntroduction to Arduino with ArduBlock & SparkFun LilyPad
Introduction to Arduino with ArduBlock & SparkFun LilyPad
 
Rasperry pi Part 13
Rasperry pi Part 13Rasperry pi Part 13
Rasperry pi Part 13
 

Recently uploaded

World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 

Recently uploaded (20)

World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 

Not so hard hardware

  • 1. ulster.ac.uk Not so hard “hardware” -Using Raspberry Pi GPIO pins with Scratch Richard Gault PhD Researcher in Computational Neuroscience Intelligent Systems Research Centre Ulster University, Magee
  • 2. Not so hard “hardware” Contents - Teaching through context and effective use of language - Evolving an open ended problem - Using the Raspberry Pi GPIO pins from Scratch - First Project: - Belisha Beacon - Extending knowledge: - Traffic Lights - Introducing Inputs: - Pedestrian Crossing (Pelican Crossing/Toucan Crossing) - Extending knowledge and introducing sensors: - Puffin Crossing
  • 3. Teaching through Context and effective use of language Benefits of Teaching through Context: - Bringing learning beyond the classroom - Encourages deeper thinking in the world around - Develops thinking from different perspectives Effective use of Language: - Closes the gap between problem solving and coding - Provides a more structured discussion for problem solving. - Helps to put students in the computer perspective
  • 4. Evolving an open ended problem All aboard ‘computing sight seeing tours’ 1 2 3 4 On the tour we will have: - Raspberry Pi/Scratch/GPIO - Electronics/Physics/Circuit Diagrams - Controlling Outputs using Scratch - Sequences - Loops: Both finite and infinite - States and state transition - Handling inputs using Scratch - Modifying behaviour to evaluate understanding of concepts - A brief glimpse at sensors
  • 5. Getting Started Main components - Raspberry Pi (RPi) (These slides are based on (RPi 1), B+ V1.2) Setting up the RPi Also see Chapter 1: Adventures in Raspberry Pi, Carrie Anne Philbin (Wiley 2014) - Students should have basic experience of using Scratch RPi 2 Model B
  • 6. GPIO pins - General purpose input/output (GPIO) pins can be used to interact with the real world. - Using these pins is completely safe, however, you should take great care when connecting cables to the GPIO pins on your Raspberry Pi (to protect you and the device). Some pins are designated as power supply (red) and others as ground (black). The rest can either be for an input or an output. Input Output
  • 7. GPIO Pins How do they work? Output: The RPi acts as both a power supply and a switch. So when we turn a particular pin on (or set it high, or to 1) in our code, we are turning on a switch. It will remain on until we set the pin to be off (or set it low, or 0).
  • 8. GPIO Pins How do they work? Inputs: Inputs are a little more tricky. For our work, if enough ‘input’ (voltage) comes in then the RPi will register that there is an input, i.e. Yes = 1, or there isn’t, i.e. No = 0.
  • 9. Using the GPIO pins from Scratch You cannot automatically control the GPIO pins from Scratch. Option 1: Pi_Scratch(Pridopia) Option 2: ScratchGPIO Option 3: ??? If you find other alternatives please share them with the CAS community!
  • 10. Getting Started with ScratchGPIO Select the right version for you: - For RPi 1, model B+ V1.2, I recommend using ScratchGPIO5 - For RPi 1 models before B+ you may need to use an earlier version - For RPi 2 with Scratch 2.0, I recommend using ScratchGPIO7 You can download and install the right version for you either straight from the internet to the RPi or first downloaded on to a memory stick and complete installation from the memory stick onto the RPi. Word of Caution! Input and Output pins are pre assigned when starting up ScratchGPIO – You can change inputs to outputs (and vice versa) later if needed. Pin naming convention -> pin11on pin11high GPIO17on GPIO17high
  • 11. Know your pin layout! RPi 2 also * You can damage the RPi by plugging components in to the wrong pins.
  • 12. Getting started with ScratchGPIO What’s going on? Once you have successfully installed ScratchGPIO: Use ScratchGPIOX …without the ‘plus’ When you open up: From ScratchGPIO we will broadcast specific messages that the scratch gpio handler will understand and execute the appropriate commands.
  • 13. Stop 1: Belisha Beacon Zebra Crossing Lesson based upon road safety and different types of crossings. What exactly is a Belisha beacon? - “It is a flashing light” - “The light turns on and then off” - “The light turns on, then after a second or two it turns off” Recipe for Belisha beacon: Ingredients will include: A light, RPi Instructions will include: Turn light on Wait 1 second Turn light off Wait 1 second
  • 14. Stop 1: Belisha Beacon Ingredients
  • 15. Stop 1:Belisha Beacon Set up: Hardware Connect the positive side of the LED to a resistor, and connect the resistor to pin 11 of the RPi. Connect the negative leg of the LED to any of the ground pins of the RPi. (see OCR Traffic Lights Recipe) Without Breadboard With Breadboard
  • 16. Stop 1: Belisha Beacon Set up: Software Start ScratchGPIO5->Go to the control tab->Use the ‘broadcast’ blocks to communicate with GPIO pins
  • 17. Stop 1: Belisha Beacon Implementing our recipe
  • 18. Stop 1: What can we really do? Also at this stop: Electronics->flow of electricity->voltage and current Resistance-> Actually calculating the voltage and current->V=IR calculations Reading resistor values->Significant figures and multiplication by 10. 1 2 3 4 Continually turn a light on and off… -Lights on an emergency vehicle -Notification light -School warning sign/train crossing -Road bollard ->Translucent/transparent/opaque materials -Traffic lights -> more complex sequences
  • 19. Stop 2: Traffic Lights The problem - First work out the traffic light sequence: - Traffic lights recipe: Ingredients will include 3 LEDs (one red, one amber/yellow, one green) and 3 resistors, jumper cables to connect RPi to components 4. 1. 2. 3.
  • 20. Stop 2: Traffic Lights Set up: Hardware See OCR traffic light recipe for set up without breadboard
  • 21. Stop 2: Traffic Lights Implementing our algorithm 4. 1. 2. 3.
  • 22. Stop 2: What do we really know? - At this stage we can still only control outputs (LEDs) - The traffic lights can be used to assess the degree of understanding students have on circuits, using GPIO pins and algorithmic design. Also at this stop: -States and state transitions. -Repeating sequences. -2 or more traffic lights 1 2 3 4
  • 23. Stop 3: Pedestrian Crossing Pelican crossing
  • 24. Stop 3: Pedestrian Crossing Introducing inputs - Now we will introduce a new element to the problem: input! - A button will be used to signal to the system there is a pedestrian ready to cross - High or low? - Let us see what happens when the button is pressed
  • 25. What does your input do? Depending on the type of switch/button and the way you construct your circuit will dictate what your system will do when the button is pushed. The state of the pin will either be of value 1, or value 0. Push button
  • 26. Stop 3: Pedestrian crossing Implementation Identifying the correct code to modify We also need red and green LEDs for the pedestrians! pin26
  • 27. Stop 3: Pedestrian Crossing Set up: Hardware
  • 29. Stop 3: Pedestrian Crossing Pelican crossing from the drivers perspective
  • 30. Stop 3: Pedestrian Crossing Pelican Crossing-modified sequence pin26 pin26
  • 31. Step 3: What do we really know? Inputs and Outputs Switch Button Microphone LED Buzzer Heater Speaker Also at this stop: -Toucan crossing - Inputs vs outputs exercise (telephone) - Pull up and pull down resistor circuits 1 2 3 4 Input Output Why not use the button as an input to a Scratch game – 4 buttons to move a character up/down/left/right. Revisit the emergency vehicle -> start flashing lights with the push of a button -> introduce sound(?)
  • 32. Stop 4: Puffin Crossing Sensors
  • 33. Stop 4: Puffin Crossing Introduction to sensors - Sensors are used to measure physical quantities such as temperature, light, pressure, sound and movement. - We will be using a passive infra-red sensor which will detect a change in motion. - If there is a change in motion, the internal properties of the sensor will change and thus the information being sent to the RPi will be different than before. - So our sensor will provide information in to our system. - We need to test our sensor value like we did with the button.
  • 34. Stop 4: Puffin Crossing Testing the PIR sensor
  • 35. pin26 Stop 4: Puffin Crossing Implementation (same hardware set up as Pelican crossing) pin26 pin7
  • 36. Stop 4: Puffin Crossing Looking at a problem from different angles Traffic lights and pedestrian crossings must account for every eventuality …as do good computer programs. This often requires you to look at a problem from various perspectives. Therefore empathy is in an important attribute to develop to become strong at problem solving and computing.
  • 37. Useful Links Components: 5mm LEDs (x20 Red, x20 green, x20 yellow, x20 blue, x20 white): £1.69* 220Ohm Resistor (x 100) : £1.49* 20cm jumper cables (x40): £1.27-£1.98* Push buttons (x100): £3.85* Passive IR motion detector: £3.13* 400 point breadboard : £1.79* Breakout board (RasPIO Pro) : £9.95 Breakout board (GPIO Cobbler+T-Cobbler+Ribbon Cable+breadboard) : £11.99 * 37 Sensor kit: £34.95* Cost for one full project: £3.64 + £11.99(optional bread board and breakout board) PiStop: (Traffic lights only) £2.10 -£2.95 (depending on quantity) *Price includes delivery
  • 39. Acknowledgements: Ann O’Neill (Stranmillis University College) Web: http://isrc.ulster.ac.uk/rgault/research.html Email: gault-r2@email.ulster.ac.uk CAS: Richard Gault (email as above) Thank you for listening!

Editor's Notes

  1. Voltage is directly proportional to energy so it can be used without loss of generality as charge will remain constant here.