Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

RMOUG QEW Family Coding Event- Raspberry PI


Published on

Raspberry Pi Coding Project

Published in: Technology
  • Be the first to comment

RMOUG QEW Family Coding Event- Raspberry PI

  1. 1. RMOUG QUARTERLY EDUCATION WORKSHOP Family Coding Day, August 7th, 2015 Elitch Gardens, Denver, CO
  2. 2. HARDWARE REQUIRED  Raspberry Pi, (any version)  Pibrella board, (this can be done without, but requires the motor to be wired directly to the pi, which is definitely not as easy… )  Accessories- monitor, keyboard, mouse and power supplies
  3. 3. HOOKUP AND STARTUP YOUR RASPBERRY PI  Ensure the Pibrella is already installed, if not, the next slide will cover and handouts are available from Kellyn.  YOU MUST protect your HDMI port from the Pibrella board. If you don’t have a buffer, (cardboard, foam, etc.) between the two, cut out a piece of cardboard or similar to stick between the metal contacts on the bottom of the pibrella board and the top of your HDMI port.
  5. 5. ART PROJECT TODAY  Using a LIGHT art project, we’ll attach the small item to a motor and control it code.  Can be a character that will dance in circles, or animal/flower that spins.  A flyer that will be launched  The art must attach to a small wooden “toothpick” or a flat stand.  What you create is UP TO YOU!
  6. 6. THIS PROJECT WILL WORK WITH DIFFERENT VERSIONS OF PYTHON…BUT  Python3 will allow you to utilize all features of the Pibrella. Connected to the wifi, install this libraries and then re-install the pibrella with new lib files: >sudo apt-get install python3-pip >sudo pip-3.2 install pibrella
  7. 7. AGAIN- THE GOAL OF TODAY’S PROJECT Create a Rotating Project of YOUR OWN design with code-  Using a simple motor and provided supplies.  Be creative and build what you want that will attach to a base or wooden stick.  Think about the different uses for this project.  Think about enhancements for your project while you’re working with it!
  8. 8. ENTER TIMING FIRST! Once the wheel and motors have been assembled and attached to the Pibrella, it is time to program them to do what they were built for... turning! On your Raspberry Pi: Open a terminal window and type vi <file_name>.py and press Enter on the keyboard. This will open a blank text editor file in which you can type your code.
  9. 9. IMPORT THE LIBRARIES  Begin your code by importing the Pibrella Python library needed to control the motor by typing: import pibrella  Underneath, import the time library in the same way so that you can add time delays to your program: import time
  10. 10. CODING AFTER TIME ENTRY  Leave a blank line of code by pressing Enter.  Underneath, you can now write the sequence of instructions to control the attached motor: pibrella.output.e.on() time.sleep(10) To exit out of the program, type in: quit()  Press Esc :wq to save and quit.
  11. 11. CODE SHOULD LOOK LIKE THIS import pibrella import time <enter break line in code> pibrella.output.e.on() #turn on time.sleep(10) #spin for 10sec #turn off quit()
  12. 12. HOOK UP YOUR ENGINE TO THE PIBRELLA  Your Setup should look like the following:  Wires red to posistive, black to negative.  Most likely hooked up to D, but could be to E, (top right of red button for a few)
  13. 13. ATTACH YOUR ART PROJECT AND RUN  Now that you tested successfully, add your art project with whatever type base to the motor and run again.
  14. 14. RUN THE CODE  Python sudo python –i <file name>.py  Python 3 sudo python3 <file name>.py Now this just runs the engine as soon as you execute it and no control outside of that.
  15. 15. MORE ADVANCED BUTTON CONTROL import pibrella import time <line break in code> while true: <4 spcs>if <indent 8 spcs> pibrella.output.e.on() <indent 8 spcs> time.sleep(0.01) <indent 8 spcs> <indent 8 spcs> pibrella.output.e.on() <indent 8 spcs> time.sleep(0.02) <indent 8 spcs> <indent 8 spcs> break Save File
  16. 16. RUN THE CODE  Python sudo python –i <file name>.py  Python 3 sudo python3 <file name>.py NOW, push the button to execute the spin! How did you spin timing and motor power combination do? Do you need to add or subtract time to your project?
  17. 17. LAUNCHING “FLYERS”  Attach your Flyer, (spinner or other design) to your engine.  Ensure it’s stable enough to spin, but not too tight that it won’t launch.
  18. 18. CODE THE FOLLOWING import pibrella import time <line break in code> while true: <4 spcs>if <indent 8 spcs> pibrella.output.e.on() <indent 8 spcs> time.sleep(30) <indent 8 spcs> <indent 8 spcs> break quit() Save File with name “”
  19. 19. RUN THE CODE  Python sudo python –i  Python 3 sudo python3 The current time for the spin is 30 seconds- Is this too much? Does the engine spin long after the flyer has launched and you need to decrease it? Is it not long enough? Increase the time from time.sleep(30) to time.sleep(45) to see if that is enough.
  20. 20. ENHANCING YOUR PROJECT  How would you build out your project?  What kind of additional coding would you add?  Would your project be cooler if you added: Sound? Light? Additional Motors? Art?