

| R Pi | Arduino |
|---|---|
| multiple tasks | simple task |
| digital GPIO only | digital & analog |
| R Pi 3 | R Pi 2 B+ |
|---|---|
| quad-core 1.2GHz CPU | quad-core 900MHz CPU |
| 1GB RAM | 1GB RAM |
| Wifi | No |
| BLE | No bluetooth |
RPi 一般使用基於 Linux kernel 的作業系統
Go to RPi downloads page!
ssh is bulit-in)System Preferences > Sharing > Internet Sharinguse 192.168.137.0/24 subnet
pi for "Log in as:"ssh pi@192.168.137.10raspberry
lscdtouchrmmvcpmkdirrmdircatlessheadtailmansudoapt-get installman串接前一個 stdout 到下一個 stdin
cat /etc/passwd | awk -F: '{print $1}' | lesssyntax on
filetype indent plugin on
colorscheme torte
set nu ai ar
set ts=4 sw=4
set mouse=a
set bs=indent,eol,start ww+=<,>,[,]

It's not easy to do real-time control with RPi GPIO!!

import RPi.GPIO as GPIO
# GPIO.setmode(GPIO.BOARD)
GPIO.setmode(GPIO.BCM)GPIO.setup(chan_in, GPIO.IN)
# this will return GPIO.LOW (0) or GPIO.HIGH (1)
GPIO.input(chan_in)
GPIO.setup(chan_out, GPIO.OUT)
GPIO.setup(chan_out, GPIO.OUT, initial=GPIO.HIGH)
# this will set the output state (GPIO.LOW or GPIO.HIGH)
GPIO.output(chan_out, state)
# chan_list is a list of channel number
GPIO.output(out_list, state)
# len(chan_list) == len(state_list)
GPIO.output(out_list, state_list)GPIO.cleanup()Integrate an RFID sensor with an R Pi. The sensor can scan any easy card and do something cool.



python (built-in)SPI-Pypi-rc522websocketgit clone https://github.com/lthiery/SPI-Py
git clone https://github.com/NTUgEEk/pi-rc522
sudo pip3 install ./SPI-Py
sudo pip3 install ./pi-rc522curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt install nodejs
npm install --save websocketsudo pip3 install websockets255.255.255.255 (string)
import asyncio
@asyncio.coroutine
def compute(x, y):
print("Compute %s + %s ..." % (x, y))
yield from asyncio.sleep(1.0)
return x + y
@asyncio.coroutine
def print_sum(x, y):
result = yield from compute(x, y)
print("%s + %s = %s" % (x, y, result))
loop = asyncio.get_event_loop()
loop.run_until_complete(print_sum(1, 2))
loop.close()const spawn = require('child_process').spawn;