TeCoEd (Teaching Computing Education)
  • Home
    • Freelance
    • Book
    • Downloading
  • Python
    • Learn Python >
      • Python Modules
    • Python Programs >
      • Higher or Lower
      • Magic Calculator
      • Password Checker
      • Python Pit
    • What's News App
    • Pixels to Cells
    • Python Mosaics
    • Python OCR
    • L-1-AM
    • Web Scraping >
      • Scraping Trains
    • Weather App
    • Snakes and Windows
    • Python Web Server >
      • Flask
    • Python Picks
  • Raspberry Pi
    • All About the Pi
    • Getting Started
    • Remote Desktop and VNC
    • Static IP Address
    • Sonic Pi >
      • 3.14
    • Twitter Feed >
      • Tweepy
    • Android & Pi >
      • Advanced Apps
      • Odds
    • A.I on the the Pi
    • CRON
    • Pick Your Own
  • Pi Hardware
    • Pi HATS >
      • Sense Hat Hacks
      • AstroPi HAT
      • Unicorn-HAT >
        • Unicorn Alphabet Disco
        • Uni Codes / Programs
      • Skywriter
      • Piano HAT
    • STS Pi
    • Pi Camera >
      • Pi-Cam, Python & Email >
        • Time Lapse
      • Pi Noir
    • Pipsta >
      • Flask, Input & Printers
    • Raspberry Pi Power >
      • Energenie IR power
    • Pibrella
    • Distance Sensor
    • LCD Screen
    • Pi-Tooth
    • Robot Arm
    • PiGlow
    • PiFM
    • Accelerometer
    • PiFace >
      • Installing PiFace >
        • Python Commands
  • Pi-Hacks
    • Drone Hacks
    • Pi Glue Gun Hack
    • Blinkt!
    • Sonic Pixels
    • R2D2
    • Get to the chopper
    • Astro Bird
    • Twitter Translator
    • Hacking a Robot
    • Nature_Box >
      • Best Nature Photos
    • Wearable Tech >
      • Project New York
      • P.N.Y Part 2 Health
      • P.N.Y Part 3 Games
      • P.N.Y Part 4 Translation
    • Dino-Tweet
    • Other Links
  • Pi-Hacks 2
    • The Joker
    • Hologram Machine
    • Google Vision: Camera Tell
    • Yoda Tweets
    • Pi Phone
    • Darth Beats
    • Twitter Keyword Finder
    • Crimbo Lights Hack
    • Xmas Elf
    • Halloween 2016
    • Halloween Hack 2015
    • Socrative Zombie
    • Voice Translation
    • The Blue-Who Finder
    • GPIO, Twitter
    • Pi Chat Bot >
      • Dictionary Definitions
    • PiGlow & Email
    • Pibrella Alarm System
    • SMS with Python >
      • Spooking a Mobile
  • Pi-Hacks 3
    • Night Vision
    • Enviro+ Weather
  • Minecraft
    • Minecraft API
    • Minecraft Sweeper
    • PiGlove: Minecraft Power Up
    • Minecraft Photo-booth
    • Rendering Pixels
    • Speed Cube
    • Lucky Dip
  • Computing
    • Why Computing?
    • Can You Compute
    • micro:bit
    • Coding Resources
    • Learn to Code >
      • Coding with iPads
      • Apps Creation Tools
      • sKratchInn
      • Sound Editing
    • Cheat Sheets
    • Theory
    • HOUR OF CODING
    • BEBRAS Computing Challange
    • Computer Facts
    • Free Software and Links
  • Contact Me

I run a Raspberry Pi lunchtime club for students and they wanted to create a Star Wars hack. A local store was selling R2D2 sweet dispensers for a couple of pounds and I decided to purchase some and see what ideas the students came up with.  This is the online account of their development of the R2D2 hack.  Scroll to bottom for final project video.

The students original wanted to create an R2D2 that:
1. Prints out random Star Wars Facts - no screen used!
2. Flashes a red LED - to completed
3. Projects an image - too complicated
4. Randomly gives the user a little electric shock, just like R2D2 - simulated!
5. Takes a picture of the user -
sends a web feed instead
6. Broadcasts a song / fact onto the radio - plays the Star Wars theme tune
Picture

1. Random Fact Generator

Picture
The first step was to create a simple random fact generator using random.choice.  The facts will be downloaded from a website or written out by the students from their own knowledge.

2. Red LED

Picture
Next the students programmed the LED to turn on and off after a short delay.  This used the GPIO pins BCM numbers, (pin 21 and 39 for the ground). The long leg of the LED is the + and connected to the 3.3v pin (GPIO 9)

3. Drill the Holes

Picture
Using a drill a some delicate pressure we made a whole for the LED to fit through and used the code in step 2 to control it.

4. Web Cam Hack

Picture
Students wanted to be able to see from R2D2 what the user looked like, who had pressed the button.  We hacked an old USB Web Cam, drilled a hole in R2's head to place it.

5. Motion

Picture
'Motion' enables you to easily set up a stream from the Web Cam which you can view from most browsers.  type sudo ifconfig to find the RasPi IP address and then enter this into a browser. Lots of guides are out there: one link is here

6.Getting the Button to work

Picture
The R2D2 responds when the front button is pressed.  This is the triggers the R2D2 bleeps.  The wires were cut and two extension wires added.  These were joined to the GPIO pins and a code used to check for a Pull Up - a small change in current.

7. GPIO Pull Up

Picture
The GPIO Pull Up checks for a change in the state of the current, it basically registers a change and can be used to trigger an event.  When the main R2D2 button is pressed the GPIO change is registered and then this triggers the code the enable the LED or a Haptic Motor to start.

8. Vibe Motor

Picture
Despite the one students wish to enable R2D2 to electrocute people I felt it was not the best thing to do!  Instead we settled on a Haptic Motor which could be used to vibrate the R2D2 case and may 'shock' the person who pressed the button.

9. PiFM

Picture
The students wanted to broadcast the facts over a Radio, this makes use of PiFM, which ironically has the Star Wars them install!  It works on a single pin but testing is required to ensure that it works with all the other wires connected. 

Wiring Up


Wiring up the components to the R2D2 and Raspberry Pi was fiddly and took some time.  The droid is mounted on top of a black Pi case to hide the wires and enable the the USB and Ethernet ports to be used.  This also makes it more robust.  The webcam feed can be viewed on 192.168.1.12:9091