SlideShare une entreprise Scribd logo
1  sur  51
ScratchGPIO, Raspberry Pi &
BerryClip
KS2 Starter Guide to Physical Computing
Sense and control the physical world using computer programs running on the
Raspberry Pi. Here you will learn how easy it is to interact with the outside world, and
how this opens up limitless possibilities for exploration. A wide range of sensors,
motors, robots and USB devices can be connected.
https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/
Getting Started
• https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/getting_started/
https://www.raspberrypi.org/guides/teachers/
https://www.raspberrypi.org/resources/teach/
Desirable features Interactive Design
Scratch and BerryClip
http://www.rpischool.org.uk/?p=114
A simple way for primary school aged children to control
lights, a buzzer and use a physical button with their
scratch programs.
+
+BerryClip
Raspberry Pi
BerryClip plugs directly onto the Raspberry Pi’s GPIO header
and provides 6 coloured LEDs, 1 Buzzer, 2 Switches and a 13 pin
header. It can be controlled using any programming language
that can manipulate the GPIO pins and this includes Python
and C.
GPIO
ScratchGPIO: How to install on your Raspberry Pi
A modified version of Scratch called ScratchGPIO is needed to be able to connect to the BerryClip.
The following are instructions to install ScratchGPIO7 software on Raspberry Pi
• With Raspberry Pi connected to Internet
Copy the text below ( left click just before the s of sudo and drag right until all the text in the line as been selected) then right-click
and select copy. Open up an LX Terminal window and select Edit and the Paste that into an LX Terminal window and press Enter it to
download the installer.
wget http://bit.ly/1wxrqdp -O isgh7.sh
Once the installer has been downloaded then just type (or copy and paste the text below as before)
sudo bash isgh7.sh
and press Enter
(If logged in as a different user to standard pi, then type sudo bash isgh7.sh yourusername) This will install all the necessary extra
software and some simple examples.
http://simplesi.net/scratchgpio/scratch-raspberrypi-gpio/
•With Raspberry Pi not connected to Internet.
Power down you Pi and put the SD card into another computer and download this file
http://bit.ly/1wxrqdp
and copy it to your SD card.
Put the card back into your Pi and then open up an LX Terminal window and type the following
sudo bash /boot/install_scratchgpio7.sh
(If logged in as a different user to standard pi, then type sudo bash /boot/install_scratchgpio6.sh yourusername) This will
install all the necessary extra software and some simple examples.
The installer will create 2 desktop icons – ScratchGPIO7 which is used for beginners using simple circuits and ScratchGPIO
7Plus which is used with a lot of add-on boards.
Continue onto 1st Project
http://simplesi.net/scratchgpio/scratchgpio-1st-project/
ScratchGPIO6 was the previous version – if you need a copy of it – then click here
http://cymplecy.github.io/scratch_gpio/
Raspberry pi installation
• https://www.raspberrypi.org/documentation/installation/noobs.md
Use ‘Broadcast’ to control lights
• ScratchGPIO Run the
special Scratch icon
(ScratchGPIO) on your
desktop.
• To test out control from
Scratch, click on File then
Open and then click on
the My Projects button
and select blink11 and
click on OK. Once the
project opens, just click on
the OK to enable Remote
Sensor Connections. To
run the script just click on
the Green Flag.
Your LED should now blink on for 1
second and off for 2 seconds
(Play Video below to see)
Turn on all the BerryClip LED lights
The LEDs have a Hardware
Reference:
Use this reference in ScratchGPIO:
or = LED on
or = LED off
(All the LED’s are on)
(GPIO pin numbers/ordering do not follow anything that makes
sense to most people so you just have to go with the seemingly
random numbering arrangement)
• As you can see in the blink11 script ,
you can simply use a broadcast
message telling Pins to go on or off
(Up to 3.3V and down to 0V) The valid
messages are along with the
corresponding pin off messages.
You can also say And you can replace the word on with high and
replace off with low if you want to talk in pure logic levels.
Play video:
Using variables instead of broadcasts
For more advanced Scratchers, you can use variables instead (or as well as broadcast messages)
A broadcast allows a signal to everything with the ‘When I Receive’ to be broadcasted, and it allows different objects to do different
things all at the same time.
A custom block is a ‘Shortcut’ to a command. For example, pressing Ctrl+X cuts something much like a string of custom commands
created by you using custom blocks.
Custom Block - Allows you to create a new block which you can use in the sprite in which it is defined
Broadcast - Sends an event so all the corresponding when I receive scripts will start running
Edit: OK a broadcast can be used to replace a custom block. The custom block makes things much easier by having parameters. The
custom block also has run without screen refresh which broadcast cannot do.
• For example: create a global variable called pin11
• To make pin11 go on or off, set it to;
• ‘1’ = on
• ‘0’= off
Variables to control the GPIO’s (General Purpose In and Out)
Hardware
Reference
The following list shows
the mapping between the
components, the header
pins and the GPIO
references :
LED 1 - Pin 7 - GPIO4
LED 2 - Pin 11 - GPIO17
LED 3 - Pin 15 - GPIO22
LED 4 - Pin 19 - GPIO10
LED 5 - Pin 21 - GPIO9
LED 6 - Pin 23 - GPIO11
Buzzer - Pin 24 - GPIO8
Switch - Pin 26 - GPIO7
Make a variable for each of
the LED lights.
For example: To control the
first RED LED (LED 1) the
Hardware Reference for LED-1
is Pin 7.
Go to ‘Variables’. Click on
‘Make a variable’ call it ‘pin7’
Drag the ‘set pin7 to 0’ block
to the Sprite Script.
Create variables like this for all
the LEDs. Use the Hardware
Reference as a guide.
To turn a LED on set it to ‘1’
To turn it off set it to ‘0’
Make LED light pattern
• Once you know how to turn on an off the LED’s you can easily start to
write your own sequences.
This piece of script
when I press ‘space’
will create a looping
light cycle.
Try your own combinations of flashing lights
• Use either ‘Broadcast’ or ‘Variable’ method to create your own light
patterns, turning on and off the individual LED’s.
• Which method is easier?
• Use ‘wait’ block to vary the length of time a light stays on.
• Use ‘forever’ block to loop the pattern.
• Save your work.
Traffic lights sequence (Simple)
Lights go off in pairs in sequence like traffic lights
Traffic Lights Sequence
When flag is clicked it goes to green. Press Space to start sequence. Print PCB?
GPIO Example: control LED’s using keyboard
Ways to control LED’s using keyboard input with either
‘broadcast’ or a ’variable’.
GPIO Game BerryClip
• A simple game that uses Scratch GPIO extensions to play.
• The 3 LED’s display health/ lives of the cat
• Use buttons or arrows to move the cat up and down to avoid Rex. Be
careful, he gets faster!
LED Health Bars -Raspberry Pi, BerryClip,
ScratchGPIO
http://computers.tutsplus.com/tutorials/learn-how-to-use-
raspberry-pi-gpio-pins-with-scratch--mac-59941
Random ‘Crazy’ Lights GPIO
Disco lights
• http://pdwhomeautomation.blogspot.co.uk/2013/04/raspberry-pi-
scratch-gpio-disco-lights.html
Allpins on/off
• To set all outputs to on or off use
• For a complete list of all commands that ScratchGPIO understands
see here.
Robot Antenna project Raspberry Pi, Scratch and Breadboard
https://www.raspberrypi.org/learning/getting-started-with-scratch/worksheet/
Robot on Scratch linked with ‘Real’ robot
Pi, Breadboard, Scratch
Pi, Breadboard, Scratch
SWEET SHOP REACTION GAMEhttps://www.raspberrypi.org/learning/reaction-game/
http://www.dmict.co.uk/programming-using-a-raspberry-pi-berryclip-and-scratchgpio/
•
The 3 projects are:
1. Creating a ‘scanning’ LED sequence (Think KITT’s lights from the TV show ‘Knight
Rider’).
2. Creating a Morse code generator using the Berryclip’s buzzer.
3. Creating a working die using the 6 LEDs that is triggered by the on-board switch.
• A guide for creating these mini-projects can by downloaded from the link below, the
Scratch project files can be downloaded for modification from my Scratch page and
demos of the 3 projects are embeded below.
• 3 Raspberry Pi Berryclip mini-projects documentation
Simplesi website have the basics…
• http://simplesi.net/scratchgpio/scratchgpio-1st-project/
• I’m using this website as reference but have changed it slightly as I’m
using the BerryClip and not a Breadboard.
1st BerryClip project
Control the ‘Traffic Lights’ Manually
Remote Sensor Connections (RSC
Scratch uses this RSC feature to talk to external
devices over a network. To enable this in scratch, go
the ‘sensor’ blocks, then right click on either of the
last two blocks to find a menu item called ‘Enable
remote sensor connection’. Your scratch program
will remember this setting when you save your
scratch file. RSC has two main types of
communication:
• Broadcast messages
These are simple messages that can be sent and
received over RSC. e.g.’led1on‘
• Sensor-updates
These are special messages that pass a value
associated to a changing sensor input or
variable. These sensor updates are only sent when
a variable or sensor’s value has changed. The
berryclip push button is a simple sensor, when
pressed a value of 1 is sent, on releasing the button
a value of 0 is sent.
You should at this point be using
ScratchGPIO on your Raspberry Pi
with the BerryClip attached to it.
Now you must enable
ScratchGPIO to talk to the
BerryClip;
In Scratch, go to the ‘sensor’
block, then right click on either of
the last two blocks to find a menu
item called ‘Enable remote sensor
connection’.
SCRATCH INTERFACE DEVICE (SID
• use Scratch on a desktop/laptop PC and get it to remotely control the
GPIO pins via a WiFi connection.
HTTP://SIMPLESI.NET/SIDRPI/
Berry Bookies – A Horse Racing Game For The BerryClip
• http://www.raspberrypi-spy.co.uk/2014/01/berry-bookies-a-horse-racing-game-for-the-berryclip/
Raspberry Pi and Berry Clip
http://www.rpischool.org.uk/?p=114
• BERRYCLIP PLUS INSTRUCTIONS
• The BerryClip+ is an enhanced version of the popular BerryClip add-on board. It is a simple, cheap and easy
to use addition to the Raspberry Pi. It plugs directly onto the Pi’s GPIO header and provides 6 coloured LEDs,
1 Buzzer, 2 Switches and a 13 pin header. It can be controlled using any programming language
that can manipulate the GPIO pins and this includes Python and C.
• The 13 pin header allows additional components and sensors to be added.
• The kit includes the following parts :
• – 1 PCB
– 1 26-way header
– 1 13-way header
– 2 Red LEDs
– 2 Yellow LEDs
– 2 Green LEDs
– 1 Buzzer
– 2 Switches
– 6 330 ohm resistors
– 2 1K ohm resistors
– 2 10K ohm resistors
– 1 Rubber bumper
Pin Pattern
• To use a “bit-pattern” to set/unset multiple outputs simultaneously
use (this will set Pin 11 , Pin 13, Pin 16 and
Pin 18 on and Pins 12 and 15 off)
25 fun things to do with a Raspberry Pi
• http://www.cnet.com/uk/how-to/25-fun-things-to-do-with-a-raspberry-pi/
• https://pihw.wordpress.com/lessons/rgb-led-lessons/rgb-led-lesson-2-scratch-gpio-getting-started/
• http://www.ncl.ac.uk/computing/outreach/resources/primary/primary-conf-2014/resources/w2.4.pdf
• http://www.adafruit.com/
VGA Adaptor
• http://www.bloglovin.com/blogs/raspberry-pi-spy-
5426543?post=4101956151&group=0&frame_type=a&context=&context_ids=&blog=5426543&frame=1&click=0&user=0&viewer=true
Broadcast v custom block
Custom build an enclosure digital fabrication
https://github.com/diy-electronics/raspberrypi-b-plus-case
How To Create A Raspberry Pi Video Capture Unit
– Part 1
• http://www.raspberrypi-spy.co.uk/2014/11/how-to-create-a-
raspberry-pi-video-capture-unit-part-1/
http://uk.rs-online.com/web/b/raspberry-pi/?cm_mmc=UK-PPC-0914-_-google-_-2_UK_EN_LS_Raspberry_Pi_BMM-_-b7b28a6f-48dd-4d1c-91b5-
51884f7b1082&gclid=CIbki8_YxsgCFQUewwodaHQHFA
http://www.bitsbox.co.uk/
Where to buy a BerryClip
I bought my BerryClip + (the '+' version is red and has an extra switch button) from DAwn Robotics:
http://www.dawnrobotics.co.uk/brands/Raspberry-Pi-Spy.html
Also recommended outlets are:
https://www.modmypi.com/search/?search=berryclip
and:
https://www.m.nu/berryclip-addon-p-767.html
Berry Clip and more Pi Shoppinghttp://www.modmypi.com/raspberry-pi
Websites
• http://www.raspberrypi-spy.co.uk/
Melting ice cube game

Contenu connexe

Tendances

Arduino workshop - hello real world
Arduino workshop - hello real worldArduino workshop - hello real world
Arduino workshop - hello real world
Tom Luyten
 

Tendances (11)

IOT Talking to Webserver - how to
IOT Talking to Webserver - how to IOT Talking to Webserver - how to
IOT Talking to Webserver - how to
 
Arduino workshop - hello real world
Arduino workshop - hello real worldArduino workshop - hello real world
Arduino workshop - hello real world
 
Ardublock tutorial
Ardublock tutorialArdublock tutorial
Ardublock tutorial
 
Game Development using SDL and the PDK
Game Development using SDL and the PDK Game Development using SDL and the PDK
Game Development using SDL and the PDK
 
Advanced view arduino projects list use arduino for projects (4)
Advanced view arduino projects list  use arduino for projects (4)Advanced view arduino projects list  use arduino for projects (4)
Advanced view arduino projects list use arduino for projects (4)
 
SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013
 
T21Con 2013 SparkFun Presentation - Arduino and ArduBlock with Protosnap ProMini
T21Con 2013 SparkFun Presentation - Arduino and ArduBlock with Protosnap ProMiniT21Con 2013 SparkFun Presentation - Arduino and ArduBlock with Protosnap ProMini
T21Con 2013 SparkFun Presentation - Arduino and ArduBlock with Protosnap ProMini
 
Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0
 
Snake Game on FPGA in Verilog
Snake Game on FPGA in VerilogSnake Game on FPGA in Verilog
Snake Game on FPGA in Verilog
 
DeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel EdisonDeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel Edison
 
Get your hands dirty with Arduino
Get your hands dirty with ArduinoGet your hands dirty with Arduino
Get your hands dirty with Arduino
 

Similaire à ScratchGPIO, Raspberry Pi & BerryClip

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

Similaire à ScratchGPIO, Raspberry Pi & BerryClip (20)

Raspberry Pi Introductory Lecture
Raspberry Pi Introductory LectureRaspberry Pi Introductory Lecture
Raspberry Pi Introductory Lecture
 
Not so hard hardware
Not so hard hardwareNot so hard hardware
Not so hard hardware
 
Raspberry pi-spectrum-analyzer-display-on-rgb-led-strip
Raspberry pi-spectrum-analyzer-display-on-rgb-led-stripRaspberry pi-spectrum-analyzer-display-on-rgb-led-strip
Raspberry pi-spectrum-analyzer-display-on-rgb-led-strip
 
Meng
MengMeng
Meng
 
Meng
MengMeng
Meng
 
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
 
Introduction To Raspberry Pi with Simple GPIO pin Control
Introduction To Raspberry Pi with Simple GPIO pin ControlIntroduction To Raspberry Pi with Simple GPIO pin Control
Introduction To Raspberry Pi with Simple GPIO pin Control
 
[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
 
Python-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptxPython-in-Embedded-systems.pptx
Python-in-Embedded-systems.pptx
 
Introduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIOIntroduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIO
 
Johnny-Five
Johnny-FiveJohnny-Five
Johnny-Five
 
pcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFun
 
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game ConsoleRaspberry Pi GPIO Tutorial - Make Your Own Game Console
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
 
arduino
arduinoarduino
arduino
 
Talk at the Landelijk Architecure Congress (NL)
Talk at the Landelijk Architecure Congress (NL)Talk at the Landelijk Architecure Congress (NL)
Talk at the Landelijk Architecure Congress (NL)
 
manual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfmanual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdf
 
Raspberry Pi ppt.pptx
Raspberry Pi ppt.pptxRaspberry Pi ppt.pptx
Raspberry Pi ppt.pptx
 
Raspberry Pi ppt.pptx
Raspberry Pi ppt.pptxRaspberry Pi ppt.pptx
Raspberry Pi ppt.pptx
 
Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10
 
Intro to the raspberry pi board
Intro to the raspberry pi boardIntro to the raspberry pi board
Intro to the raspberry pi board
 

Plus de David Dryden

Plus de David Dryden (7)

Coding on iPads
Coding on iPadsCoding on iPads
Coding on iPads
 
Filmmaking shorter version
Filmmaking shorter versionFilmmaking shorter version
Filmmaking shorter version
 
Filmmaking Workshop
Filmmaking Workshop Filmmaking Workshop
Filmmaking Workshop
 
IMotion HD Guide
IMotion HD GuideIMotion HD Guide
IMotion HD Guide
 
GameMaker Pacman Tutorial
GameMaker Pacman TutorialGameMaker Pacman Tutorial
GameMaker Pacman Tutorial
 
Scratch Programming Guides A4
Scratch Programming Guides A4Scratch Programming Guides A4
Scratch Programming Guides A4
 
How To Make 3D Images
How To Make 3D ImagesHow To Make 3D Images
How To Make 3D Images
 

Dernier

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 

Dernier (20)

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 

ScratchGPIO, Raspberry Pi & BerryClip

  • 1. ScratchGPIO, Raspberry Pi & BerryClip KS2 Starter Guide to Physical Computing Sense and control the physical world using computer programs running on the Raspberry Pi. Here you will learn how easy it is to interact with the outside world, and how this opens up limitless possibilities for exploration. A wide range of sensors, motors, robots and USB devices can be connected. https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/
  • 6. Scratch and BerryClip http://www.rpischool.org.uk/?p=114 A simple way for primary school aged children to control lights, a buzzer and use a physical button with their scratch programs. + +BerryClip Raspberry Pi BerryClip plugs directly onto the Raspberry Pi’s GPIO header and provides 6 coloured LEDs, 1 Buzzer, 2 Switches and a 13 pin header. It can be controlled using any programming language that can manipulate the GPIO pins and this includes Python and C. GPIO
  • 7. ScratchGPIO: How to install on your Raspberry Pi A modified version of Scratch called ScratchGPIO is needed to be able to connect to the BerryClip. The following are instructions to install ScratchGPIO7 software on Raspberry Pi • With Raspberry Pi connected to Internet Copy the text below ( left click just before the s of sudo and drag right until all the text in the line as been selected) then right-click and select copy. Open up an LX Terminal window and select Edit and the Paste that into an LX Terminal window and press Enter it to download the installer. wget http://bit.ly/1wxrqdp -O isgh7.sh Once the installer has been downloaded then just type (or copy and paste the text below as before) sudo bash isgh7.sh and press Enter (If logged in as a different user to standard pi, then type sudo bash isgh7.sh yourusername) This will install all the necessary extra software and some simple examples. http://simplesi.net/scratchgpio/scratch-raspberrypi-gpio/
  • 8. •With Raspberry Pi not connected to Internet. Power down you Pi and put the SD card into another computer and download this file http://bit.ly/1wxrqdp and copy it to your SD card. Put the card back into your Pi and then open up an LX Terminal window and type the following sudo bash /boot/install_scratchgpio7.sh (If logged in as a different user to standard pi, then type sudo bash /boot/install_scratchgpio6.sh yourusername) This will install all the necessary extra software and some simple examples. The installer will create 2 desktop icons – ScratchGPIO7 which is used for beginners using simple circuits and ScratchGPIO 7Plus which is used with a lot of add-on boards. Continue onto 1st Project http://simplesi.net/scratchgpio/scratchgpio-1st-project/ ScratchGPIO6 was the previous version – if you need a copy of it – then click here
  • 10. Raspberry pi installation • https://www.raspberrypi.org/documentation/installation/noobs.md
  • 11. Use ‘Broadcast’ to control lights • ScratchGPIO Run the special Scratch icon (ScratchGPIO) on your desktop. • To test out control from Scratch, click on File then Open and then click on the My Projects button and select blink11 and click on OK. Once the project opens, just click on the OK to enable Remote Sensor Connections. To run the script just click on the Green Flag. Your LED should now blink on for 1 second and off for 2 seconds (Play Video below to see)
  • 12. Turn on all the BerryClip LED lights The LEDs have a Hardware Reference: Use this reference in ScratchGPIO: or = LED on or = LED off (All the LED’s are on) (GPIO pin numbers/ordering do not follow anything that makes sense to most people so you just have to go with the seemingly random numbering arrangement)
  • 13. • As you can see in the blink11 script , you can simply use a broadcast message telling Pins to go on or off (Up to 3.3V and down to 0V) The valid messages are along with the corresponding pin off messages. You can also say And you can replace the word on with high and replace off with low if you want to talk in pure logic levels. Play video:
  • 14. Using variables instead of broadcasts For more advanced Scratchers, you can use variables instead (or as well as broadcast messages) A broadcast allows a signal to everything with the ‘When I Receive’ to be broadcasted, and it allows different objects to do different things all at the same time. A custom block is a ‘Shortcut’ to a command. For example, pressing Ctrl+X cuts something much like a string of custom commands created by you using custom blocks. Custom Block - Allows you to create a new block which you can use in the sprite in which it is defined Broadcast - Sends an event so all the corresponding when I receive scripts will start running Edit: OK a broadcast can be used to replace a custom block. The custom block makes things much easier by having parameters. The custom block also has run without screen refresh which broadcast cannot do. • For example: create a global variable called pin11 • To make pin11 go on or off, set it to; • ‘1’ = on • ‘0’= off
  • 15. Variables to control the GPIO’s (General Purpose In and Out) Hardware Reference The following list shows the mapping between the components, the header pins and the GPIO references : LED 1 - Pin 7 - GPIO4 LED 2 - Pin 11 - GPIO17 LED 3 - Pin 15 - GPIO22 LED 4 - Pin 19 - GPIO10 LED 5 - Pin 21 - GPIO9 LED 6 - Pin 23 - GPIO11 Buzzer - Pin 24 - GPIO8 Switch - Pin 26 - GPIO7 Make a variable for each of the LED lights. For example: To control the first RED LED (LED 1) the Hardware Reference for LED-1 is Pin 7. Go to ‘Variables’. Click on ‘Make a variable’ call it ‘pin7’ Drag the ‘set pin7 to 0’ block to the Sprite Script. Create variables like this for all the LEDs. Use the Hardware Reference as a guide. To turn a LED on set it to ‘1’ To turn it off set it to ‘0’
  • 16. Make LED light pattern • Once you know how to turn on an off the LED’s you can easily start to write your own sequences. This piece of script when I press ‘space’ will create a looping light cycle.
  • 17.
  • 18.
  • 19.
  • 20. Try your own combinations of flashing lights • Use either ‘Broadcast’ or ‘Variable’ method to create your own light patterns, turning on and off the individual LED’s. • Which method is easier? • Use ‘wait’ block to vary the length of time a light stays on. • Use ‘forever’ block to loop the pattern. • Save your work.
  • 21. Traffic lights sequence (Simple) Lights go off in pairs in sequence like traffic lights
  • 22. Traffic Lights Sequence When flag is clicked it goes to green. Press Space to start sequence. Print PCB?
  • 23. GPIO Example: control LED’s using keyboard Ways to control LED’s using keyboard input with either ‘broadcast’ or a ’variable’.
  • 24. GPIO Game BerryClip • A simple game that uses Scratch GPIO extensions to play. • The 3 LED’s display health/ lives of the cat • Use buttons or arrows to move the cat up and down to avoid Rex. Be careful, he gets faster!
  • 25. LED Health Bars -Raspberry Pi, BerryClip, ScratchGPIO http://computers.tutsplus.com/tutorials/learn-how-to-use- raspberry-pi-gpio-pins-with-scratch--mac-59941
  • 28. Allpins on/off • To set all outputs to on or off use • For a complete list of all commands that ScratchGPIO understands see here.
  • 29. Robot Antenna project Raspberry Pi, Scratch and Breadboard https://www.raspberrypi.org/learning/getting-started-with-scratch/worksheet/ Robot on Scratch linked with ‘Real’ robot
  • 32. SWEET SHOP REACTION GAMEhttps://www.raspberrypi.org/learning/reaction-game/
  • 33. http://www.dmict.co.uk/programming-using-a-raspberry-pi-berryclip-and-scratchgpio/ • The 3 projects are: 1. Creating a ‘scanning’ LED sequence (Think KITT’s lights from the TV show ‘Knight Rider’). 2. Creating a Morse code generator using the Berryclip’s buzzer. 3. Creating a working die using the 6 LEDs that is triggered by the on-board switch. • A guide for creating these mini-projects can by downloaded from the link below, the Scratch project files can be downloaded for modification from my Scratch page and demos of the 3 projects are embeded below. • 3 Raspberry Pi Berryclip mini-projects documentation
  • 34. Simplesi website have the basics… • http://simplesi.net/scratchgpio/scratchgpio-1st-project/ • I’m using this website as reference but have changed it slightly as I’m using the BerryClip and not a Breadboard.
  • 35. 1st BerryClip project Control the ‘Traffic Lights’ Manually Remote Sensor Connections (RSC Scratch uses this RSC feature to talk to external devices over a network. To enable this in scratch, go the ‘sensor’ blocks, then right click on either of the last two blocks to find a menu item called ‘Enable remote sensor connection’. Your scratch program will remember this setting when you save your scratch file. RSC has two main types of communication: • Broadcast messages These are simple messages that can be sent and received over RSC. e.g.’led1on‘ • Sensor-updates These are special messages that pass a value associated to a changing sensor input or variable. These sensor updates are only sent when a variable or sensor’s value has changed. The berryclip push button is a simple sensor, when pressed a value of 1 is sent, on releasing the button a value of 0 is sent. You should at this point be using ScratchGPIO on your Raspberry Pi with the BerryClip attached to it. Now you must enable ScratchGPIO to talk to the BerryClip; In Scratch, go to the ‘sensor’ block, then right click on either of the last two blocks to find a menu item called ‘Enable remote sensor connection’.
  • 36. SCRATCH INTERFACE DEVICE (SID • use Scratch on a desktop/laptop PC and get it to remotely control the GPIO pins via a WiFi connection. HTTP://SIMPLESI.NET/SIDRPI/
  • 37. Berry Bookies – A Horse Racing Game For The BerryClip • http://www.raspberrypi-spy.co.uk/2014/01/berry-bookies-a-horse-racing-game-for-the-berryclip/
  • 38. Raspberry Pi and Berry Clip http://www.rpischool.org.uk/?p=114 • BERRYCLIP PLUS INSTRUCTIONS • The BerryClip+ is an enhanced version of the popular BerryClip add-on board. It is a simple, cheap and easy to use addition to the Raspberry Pi. It plugs directly onto the Pi’s GPIO header and provides 6 coloured LEDs, 1 Buzzer, 2 Switches and a 13 pin header. It can be controlled using any programming language that can manipulate the GPIO pins and this includes Python and C. • The 13 pin header allows additional components and sensors to be added. • The kit includes the following parts : • – 1 PCB – 1 26-way header – 1 13-way header – 2 Red LEDs – 2 Yellow LEDs – 2 Green LEDs – 1 Buzzer – 2 Switches – 6 330 ohm resistors – 2 1K ohm resistors – 2 10K ohm resistors – 1 Rubber bumper
  • 39. Pin Pattern • To use a “bit-pattern” to set/unset multiple outputs simultaneously use (this will set Pin 11 , Pin 13, Pin 16 and Pin 18 on and Pins 12 and 15 off)
  • 40. 25 fun things to do with a Raspberry Pi • http://www.cnet.com/uk/how-to/25-fun-things-to-do-with-a-raspberry-pi/ • https://pihw.wordpress.com/lessons/rgb-led-lessons/rgb-led-lesson-2-scratch-gpio-getting-started/ • http://www.ncl.ac.uk/computing/outreach/resources/primary/primary-conf-2014/resources/w2.4.pdf • http://www.adafruit.com/
  • 43.
  • 44. Custom build an enclosure digital fabrication https://github.com/diy-electronics/raspberrypi-b-plus-case
  • 45. How To Create A Raspberry Pi Video Capture Unit – Part 1 • http://www.raspberrypi-spy.co.uk/2014/11/how-to-create-a- raspberry-pi-video-capture-unit-part-1/
  • 48. Where to buy a BerryClip I bought my BerryClip + (the '+' version is red and has an extra switch button) from DAwn Robotics: http://www.dawnrobotics.co.uk/brands/Raspberry-Pi-Spy.html Also recommended outlets are: https://www.modmypi.com/search/?search=berryclip and: https://www.m.nu/berryclip-addon-p-767.html
  • 49. Berry Clip and more Pi Shoppinghttp://www.modmypi.com/raspberry-pi