ppt - Avon High School Tech Crew

advertisement
V2013.14
Agenda
• 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
Executive Committee
• 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 10th Meeting: 6:00 – 7:30PM
• Present on a topic of our choice
• Volunteers?
Avon High School Tech Club
4
Avon Library Explorers Program
• June 24th at the Avon Public Library
– Mini Explorers (Pre K - Kindergarten)
• 12:30-1:30 PM
– Explorers (1st - 5th Grade)
• 2:00 -3:00 PM
• 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
Weekly Quiz
• 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?
– free -h
• Which command shows a list of commands you recently typed?
– history
• What command would you use to reconfigure the Raspberry Pi?
– sudo raspi-config
• What Raspberry Pi feature will we use to communicate with offboard sensors?
– GPIO
• 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 hellopi.py file using nano as follows:
nano -c hellopi.py
• Within our hellopi.py file, add the following code:
#!/usr/bin/python
#hellopi.py
print ("Hello Raspberry Pi")
• When done, save and exit (Ctrl + X, Y, and Enter)
• To run the file, use the following command:
python hellopi.py
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
1.
2.
3.
4.
Avon High School Tech Club
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
1.
2.
Avon High School Tech Club
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
Backup Slides
Avon High School Tech Club
19
How do Python Programs Run?
Avon High School Tech Club
20
Download