Created Thursday 29 May 2014
http://www.raspberrypi.org/forums/viewtopic.php?f=44&t=46881
Nối Rpi và Uno qua cổng USB.
Dùng software viết sẵn để điều khiển: The software is called Nanpy and was written by Andrea Stagi, [email protected], who wrote about it in MagPi issue 8, page 12.
Có protocol phổ biến là Firmata: http://firmata.org/wiki/Main_Page
The Arduino really needs to be connected via a powered USB hub so that it does not take too much power from the RPi.
Nâng cao: Có thể thêm một NPN transistor nối với 1 chân GPIO của RPi để kéo chân reset của Uno xuống đất -> tắt Uno cho đến khi cần dùng thì bật lên.
Phương án nối RPi và nhiều Arduino qua I2C: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=44&t=46969
Nối qua I2C mà dùng RPi làm master và Arduino làm slave thì không cần level shift, vì Arduino thiếu "pull-up" resistor nguồn 5V từ Arduino không cấp cho đường I2C, lúc đó đường I2C chỉ lấy nguồn 3.3V từ RPi nên không sợ cháy chân:
http://raspberrypi.stackexchange.com/questions/12636/safest-way-to-connect-raspberry-pi-to-arduino-uno-r3
The short answer to your question, how to safely connect the RPi to an Arduino, is indeed given at the first link you posted: http://blog.oscarliang.net/raspberry-pi-arduino-connected-i2c/. I have used the method given there with great success, and without damaging any components.
But your question suggests that you don't trust that method, and I think the key to trusting it is in understanding why it is safe. This is explained in the paragraph after the one you cited, but perhaps with too much detail. The key is the lack of a "pull-up" resistor on the 5V Arduino. Without it, the only voltage supply is from the 3.3V RPi, which fortunately is high enough for the Arduino to recognize.
Linh kiện
- Arduino Uno
- Cáp nối USB từ Raspberry Pi sang Arduino Uno
Nội dung
Dẫn nhập (1 trang)
- các linh kiện cần thiết
- ý nghĩa của bài học này, có thể phát triển ra những ứng dụng nào
Kết nối mạch điện tử (1 trang - hình ảnh)
- hình chụp mạch & breadboard đã kết nối
- coi như khi có sơ đồ nối dây là người ta làm theo được, không cần hướng dẫn từng bước
Chuẩn bị phần mềm (1 trang)
- liệt kê các bước bằng text
- chụp hình màn hình khi chọn menu để vào môi trường nhập lệnh (console)
Code mẫu (1 trang)
- nhập code và xem kết quả:
- nhập các lệnh điều khiển
Giải thích các lệnh (3 trang )
- thêm một phần giải thích việc nhập code kiểu interactive (nhập, gõ enter, thấy kết quả ngay, không có biên dịch hay phải nạp vào chip)
- (dự kiến khối lệnh ở mỗi bài trong vòng 20 - 40 dòng)
Bài thực hành thêm (1 trang)