發表文章

目前顯示的是 5月, 2015的文章

入門第一課:Raspberry Pi 初體驗 (閃爍LED)

圖片
約 2 年前買了一台 Raspberry Pi   ,但是一直放著沒有時間玩,最近終於想到它的存在。 個人在20年前專科時代就有玩過 8051 的微處理機,那時候寫程式相對的麻煩。 接線路也很麻煩,需要剪線、測長度,現在都有杜邦線這種現成做好的。 電子電路元件的觀念都還有印像,但是年久失修需要一段時間回憶。 底下這兩篇很適合入門的第一課: Raspberry Pi 教學 http://www.raspberrypi.com.tw/category/%E6%95%99%E5%AD%B8/ 基本電路元件解說 http://www.codedata.com.tw/java/java-embedded-6-raspberry-pi-gpio/ 線路接線:(請參考上面兩篇) LED_PIN 的輸出電位用的針腳是 12 port ,記得接對線路。 再 pi 內用編輯寫下面的程式碼:(RPi,GPIO 也請參考上面兩篇的說明安裝 pyhton lib) pi@raspberrypi ~/code $ cat led_blink.py import RPi.GPIO as GPIO import time # define pin 12, RPi P1. 2011.12 version. LED_PIN = 12   GPIO.setmode(GPIO.BOARD) GPIO.setup(LED_PIN, GPIO.OUT) try:     while True:         print("LED is on")         GPIO.output(LED_PIN, GPIO.HIGH)         time.sleep(1)         print("LED is off")         GPIO.output(LED_PIN, GPIO.LOW)         time.sleep(1) exc...

Raspberry Pi 影像檔安裝及使用

圖片
(1) 到 Raspberry Pi 官方網站抓取最新的影像檔案 https://www.raspberrypi.org/downloads/ 我是抓  RASPBIAN 這個版本,他相當於 debian 的 wheezy 版本 Download:  http://downloads.raspberrypi.org/raspbian_latest  抓好後解壓縮會得到一個 image 檔,可以使用 windows 的 image 工具寫入到 SD 卡內。 官方建議 windows 使用: http://sourceforge.net/projects/win32diskimager/ 來寫入, (2) 完成後 把線路接好, SD 卡插入機器後準備登入。 如果你和我一樣,沒有螢幕可以找台 AP 透過 AP 界面知道 PI 自動取得的 IP ,再使用 SSH 登入就可以了。 PI 預設帳密: 帳號:pi 密碼:raspberry 可以用 sudo 轉換為 root (3) 使用 ssh 登入系統: mtchang@debian:~$ ssh pi@192.168.1.191 pi@192.168.1.191's password: Linux raspberrypi 3.18.11+ #781 PREEMPT Tue Apr 21 18:02:18 BST 2015 armv6l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. NOTICE: the software on this Raspberry Pi has not been fully configure...