RaspberryPi GPIO Tutorial: LEDs and buttons

From Catrobat
Revision as of 18:04, 19 August 2016 by Administrator (Talk | contribs)

Jump to: navigation, search

Link to this page: catrob.at/RaspberryPi

First steps with Raspberry Pi in Pocket Code: create blinking LEDs, use buttons as input

What you will learn:

  • set up your Raspberry Pi
  • control LEDs/outputs from Pocket Code
  • use buttons/inputs from a Raspberry Pi in Pocket Code

If you encounter any bugs, please let us know and file a report. Thank you!

Install RaspberinoServer on your Raspberry Pi

For the following steps, you either have to enter the following commands in the terminal of your Raspberry Pi using a keyboard and a display, or you can connect to your Raspberry Pi via SSH from your computer or phone.

  1. Download the installer
    wget http://catrob.at/installraspberino -O install-raspberino.sh
  2. Run the installer as root
    sudo sh install-raspberino.sh
    Enter "y" to start the installation
    The installer downloads the server and installs everything. From now on the RaspberinoServer should be ready to use and start automatically when the Raspberry Pi is powered on.
To update the server, just run the installer again (Step 2).

Enable and Configure Raspberry Pi in Pocket Code

If you haven't already done so, you'll have to enable and configure your Raspberry Pi under Settings in "Raspberry Pi bricks". Otherwise you can skip this section and move straight to the tutorials.

   #tick the check-box to enable Raspberry Pi bricks
   #change the settings if necessary:
       ##enter IP-/Host-Address
           ###very often "raspberrypi" works as default host address
           ###if your RPi has a keyboard + monitor: find out the IP-address from a terminal via ifconfig
           ###your router might list all connected computers within the network
           ###if all of that fails: find out the IP-address via nmap
           ###the default is 10000
           (don't change it unless you changed the script on the Raspberry Pi)
       ##GPIO version
           ###select the Raspberry Pi model you are using.

The Raspberry Pi Bricks and Sensor in a Nutshell



Tutorial 1: Blinking LED (Hello World)

Tutorial 2: Dimming a LED (PWM)

Tutorial 3: read input values

Tutorial 4: recognize input events (The invisible bird)

Further project ideas

Related articles