Raspberry Pi and Python 教學筆記
2015-12-16
開源理念
Github's youtube channel: Anna's Story
Open source projects by Google, Facebook, Apple, Github, Muan & YOU
三個動詞
How we hack - Google. Collaborate. Build.
四個週三
- Demo my projects
- Review my code
- Review your code
- Demo your projects
原創專案
- 抄讚的顯示器 (an IoT app)
- ㄤㄤㄤ制約器 → 宅宅辨識
- 霹靂車頭燈 → 淡水阿嬤拇指關節復健
- 電子十八啦
- 光控開關
- PM2.5紅綠燈 (an IoT app)
- 溫度小數據 (an IoT app)
- LED看板
- LED小龍
- 十字路口 → 按鈕提早切換
一些名詞
APP = App = Application = 應用(程式/程序/軟體)
Internet = 網際網路 = 互聯網
IoT = Internet of Things = 物聯網
Raspberry Pi vs Arduino ~ Computer vs Calculator
樹莓派二
GPIO = General Purpose Input/Output → monitor/control things → IoT
RaspberryPi.org & official documentation
作業系統
官網下載NOOBS,解壓縮存SD卡
安裝作業系統 = RPi + SD + K/V/M + 網路線 + 電源線
安裝遠端桌面 = 在 Terminal 下 sudo apt-get install xrdp
Linux, Windows, OS X, iOS, Android
Linux is a MUST to learn for hackers
程式語言
The 2015 Top Ten Programming Languages
Python.org & official documentation & documentation on RaspberryPi.org
Learn 2 languages at 1 time on Codecademy
開發模式
開發模式一:登入共用的遠端桌面,用 IDLE,或在 Terminal 下 python some-script.py
開發模式二:登入個別的 Terminal,下 python some-script.py
遠端桌面連線 → 電腦172.19.16.10X → 帳號pi → 密碼raspberry → 登入遠端桌面
在 Terminal 下 Linux 指令,開每位組員個人資料夾
- ls
- cd Desktop
- ls
- mkdir my_workspace
- ls
MobaXterm → 點Session → 點SSH → host打172.19.16.10X → 勾Specify username → 打帳號pi → 點Advanced SSH settings → 勾Follow SSH path → 按OK → 敲密碼raspberry → 登入 Terminal
在 Terminal 下 Linux 指令,開 Python script
- ls
- cd Desktop
- ls
- cd my_workspace
- ls
- touch hello.py
- ls
- python hello.py
2015-12-23
Programming
變數(variable) 串列(list) k[1:3]
函數(function) len() range() k.append('haha')
選擇:
- if len(a_list) > 2:
- print 'length of a_list is bigger than 2'
- else:
- print 'length of a_list is not bigger than 2'
迴圈:
- a_list=['Y','U','C','S','H']
- for each in a_list:
- print each
Circuit
所以 電阻(器)可以限流 & 分壓
開(open) & 關(close) & 短(short)
二極體 & LED = Light-Emitting Diode = 發光二極體
三用電表 & 麵包版
- import RPi.GPIO as GPIO
- import time
- GPIO.setmode(GPIO.BCM)
- GPIO.setwarnings(False)
- GPIO.setup(15, GPIO.OUT)
- while True:
- GPIO.output(15, True)
- time.sleep(1)
- GPIO.output(15, False)
- time.sleep(0.5)
- GPIO.cleanup()
2015-12-30
Code review
複製y118專案庫
- git clone https://github.com/x1001000/y118.git
按鈕開關(Switch, SW)電路原理
重置y118專案庫
- git reset --hard HEAD && git pull
2016-01-06
Preparation
Record?
Beginning
You're more powerful than you think
Demo
Q&A
Ending