250 likes | 352 Views
Intro to Raspberry Pi Brad Luyster BradLuyster@gmail.com. Before We Start. Windows Users Go to http://files.lvl1.org from your web browser Navigate to “Raspberry Pi Boot Camp” Download all the files, then Install RealTerm, Win32DiskImager and Putty (Keep the .img file for later)
E N D
Intro to Raspberry Pi Brad Luyster BradLuyster@gmail.com
Before We Start Windows Users Go to http://files.lvl1.org from your web browser Navigate to “Raspberry Pi Boot Camp” Download all the files, then Install RealTerm, Win32DiskImager and Putty (Keep the .img file for later) Linux/Mac Users Go to http://files.lvl1.org from your web browser Download “2013-07-26-wheezy-raspbian.img” Install Picocom (Or know how to use screen to open a serial port) Know how to use “dd” and “ssh”
What is the Raspberry Pi? $35! Wow!
Raspberry Pi I/O http://elinux.org/RPi_Hardware http://elinux.org/RPi_VerifiedPeripherals http://elinux.org/Rpi_Low-level_peripherals
Raspberry Pi OS Raspberry Pi is a full blown computer Runs Linux Windows Licensing restrictions make that a non-starter You're going to learn how to use Linux, yay!
Running your Pi Software Windows Win32DiskImager RealTerm Linux/Mac Picocom Hardware SD Card USB Cable Serial Adapter
Pi OS Choices • Raspbian • ArchArm • PiDora
Installing the Image Windows Extract Image file to SD Card using Win32DiskImager (Select Image file and SD Drive) Linux Use “dd bs=4M if=[IMAGE FILE] of=/dev/sd[DRIVE]” Be very careful to select the correct “of” drive.
Connect the Serial Black to GND White to TXD Green to RXD RED IS DISCONNECTED
Logging in to Pi Username is “pi” Password is “raspberry” You are now at a Linux Console
Linux Console Basics “ls”: List files in the current directory “cd”: Change Directory “cp”: Copy File “mkdir”: Make Directory “nano”: Open Text File Editor
Config On first boot, run “sudo raspi-config” Sudo – Super User Do Needed to do risky things on Linux Expand Filesystem is the most important thing to do here Reboot Afterward
Hello World! • Grab and LED, and and a 560 ohm Resistor (Green, Blue, Brown) • Resistor to GND • Short LED leg to resistor • Long LED leg to #4
Hello World • At the console, type “sudo python” and press enter to open python • “import RPi.GPIO as GPIO” to import the GPIO module • “GPIO.setmode(GPIO.BCM)” to set board pin numbering • “GPIO.setup(4, GPIO.OUT)” • “GPIO.output(4, GPIO.HIGH)” to turn LED on • “GPIO.output(4, GPIO.LOW)” to turn LED off
More Advanced “Hello World” • import RPi.GPIO as GPIO • import time • GPIO.setmode(GPIO.BCM) • GPIO.setup(4, GPIO.OUT) • while(1): • GPIO.output(4, GPIO.HIGH) • time.sleep(1) • GPIO.output(4, GPIO.LOW) • time.sleep(1)
Inputs Put switch in breadboard. Connect 10k resistor (Brown Black Red) between 3.3v and switch Connect other side of switch to GND Connect side with resistor to #17
Polled Inputs import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(4, GPIO.OUT) GPIO.setup(17, GPIO.IN) while(1): if GPIO.input(17) == GPIO.LOW: GPIO.output(4, GPIO.HIGH) else: GPIO.output(4, GPIO.LOW)
Interrupt Inputs import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(4, GPIO.OUT) GPIO.setup(17, GPIO.IN) def my_callback(channel): print("Switch Pressed!") GPIO.add_event_detect(17, GPIO.FALLING, callback=my_callback) while(1): pass
Debounced Interrupts import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(4, GPIO.OUT) GPIO.setup(17, GPIO.IN) def my_callback(channel): print("Switch Pressed!") GPIO.add_event_detect(17, GPIO.FALLING, callback=my_callback, bouncetime=200) while(1): pass
Networked Pi Plug in your network cable Type “ifconfig” to get network interface config Note the “inet addr” for “eth0”
Networked Pi “sudo apt-get update” “sudo apt-get upgrade” Upgrades all software packages “sudo apt-get install [package]” to install new Try it now! “sudo apt-get install sl”
Resources Buy a Pi Element14 RS Electronics *** MCM Electronics *** Buy Pi Stuff *** MCM Electronics *** Adafruit Learn Learn.adafruit.com Raspberrypi.org Elinux.org LVL1!