Transcript ppt - Avon High School Tech Crew
• Old Business – – – Executive Committee LCCUG meeting volunteer(s) Reward Points Program • New Business – – Weekly Quiz Updated Website • Raspberry Pi Sensor Project – Intro to Python – LED Avon High School Tech Club 2
• President – Name • Vice President – Name • Communications Director – Name • Treasurer – Name • Term begins next school year Avon High School Tech Club 3
Lorain County Computer User Group
• Website: www.lccug.com
• Established around 1990 • The majority of their members are retired • Have a variety of knowledge and skills • June 10 th Meeting: 6:00 – 7:30PM • Present on a topic of our choice • Volunteers?
Avon High School Tech Club 4
Avon Library Explorers Program
• June 24 th – at the Avon Public Library Mini Explorers (Pre K - Kindergarten) • 12:30-1:30 PM – Explorers (1 st - 5 th • 2:00 -3:00 PM Grade) • Theme is “
Fun with Robotics
” • Game/activity/experiment that will be engaging, but not too advanced for respective age groups • Any kid-friendly games or activities that we want to develop would be perfect Avon High School Tech Club 5
• What command should you use to immediately & gracefully shutdown and halt the Raspberry Pi?
sudo shutdown –h now
• What command would you use to find the amount of free memory?
• Which command shows a list of commands you recently typed?
• What command would you use to reconfigure the Raspberry Pi?
• • What Raspberry Pi feature will we use to communicate with off board sensors?
No perfect scores!
Avon High School Tech Club 6
Reward Points Program
• Earn reward points for: – – – – – Completing surveys, polls, etc.
Completing weekly tasks Completing projects Participate during meetings Volunteer opportunities • Redeem points for: – – Tech Club gear Other prizes • Create reward levels Avon High School Tech Club 7
Raspberry Pi Sensor Project
• Goals for today: – – – Editors Intro to Python Connect LED Avon High School Tech Club 8
Getting Started: Editors
• nano • IDLE • Geany Avon High School Tech Club 9
Our First Python Program
• Create the
file using nano as follows:
nano -c hellopi.py
• Within our
file, add the following code:
print ("Hello Raspberry Pi")
• When done, save and exit (
) • To run the file, use the following command:
Avon High School Tech Club 10
Challenges for Reward Points
• Change “Hello Raspberry Pi” text to red • Show CPU speed or Temperature • Add ‘LED on/LED off’ to blink code • Have the on/off message coincide with LED • See website code samples for guidance Avon High School Tech Club 11
Using GPIO: Raspberry Pi Pinout
Avon High School Tech Club 12
Using GPIO: Power a LED
Avon High School Tech Club 1.
Resistor connects between Ground and LED cathode (short lead) Connect jumper from 3.3v to LED anode (long lead) Connect black wire to Ground, pin 6 Connect red wire to 3.3v, pin 1 13
Using GPIO: Code to Blink LED #!/usr/bin/env python # Must be run as root: sudo python blink11led.py # Import necessary modules # Provides various time-related functions import time # Control Raspberry Pi GPIO channels import RPi.GPIO as GPIO
Avon High School Tech Club 14
Using GPIO: Code to Blink LED # Blinking function, turns LED on/off def blink(pin): # Turn LED on GPIO.output(pin, GPIO.HIGH) # Pause for 1 second time.sleep(1) # Turn LED off GPIO.output(pin, GPIO.LOW) # Pause for 1 second time.sleep(1) return
Avon High School Tech Club 15
Using GPIO: Code to Blink LED # Use Raspberry Pi board pin numbers GPIO.setmode(GPIO.BOARD) # Set the output channel/pin GPIO.setup(11, GPIO.OUT) # Blink LED 10 times for i in range(0,10): blink(11) # Reset any GPIO pins when you exit the program GPIO.cleanup()
Avon High School Tech Club 16
Using GPIO: Blinking LED
Avon High School Tech Club 1.
Remove red wire Connect yellow wire from pin 11 to anode of LED (long lead) 17
More Python Fun
• Code samples: – – Add colors to terminal Get system information • See our webpage under ‘Raspberry Pi Workshop’ – Look for ‘additional Python examples to try!’ Avon High School Tech Club 18
Avon High School Tech Club
How do Python Programs Run?
Avon High School Tech Club 20