or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
Arduino講義:電算機 Serial Communication (I2C)
Introduction of I2C
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →I2C Bus協定
閒置( idle )時兩者皆為高電位。
START condition:SCL為 HIGH時,SDA發生下緣
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →先傳地址( slave address,決定跟哪個 slave 溝通),再傳資料。地址有 7bit跟 10bit兩種。
地址:由於地址為 7bit,因此在傳第一個 byte的時候,前 7bit(MSB 為 address,最後的 bit 為 R/W bit,指定要"讀"或"寫"資料(0:write,1:Read)。
只在 SCL 為 HIGH 時,才會對 SDA 取樣。 SCL 為 LOW 時,不會取樣,但可改變資料。
STOP condition:SCL為 HIGH時,SDA發生上緣
ACK/NACK機制
(注意:發送端不一定是master,ex:讀取資料時,發送端為slave)
實際傳輸的狀況
note:傳地址後的 acknowledge bit 必為 slave 傳送給 master;傳送 Data 後的 acknowledge bit 則須視前面 R/W 的值而定。
Wire函數:
note:在無(address)時,Arduino 是作為I2C的 master;有(address)時,是作為 I2C 的 slave 。
LAB1
master 把串口收到的資料,發送給 slave:

slave 端直接處理接收回來的資料:
若使用的 Arduino IDE 版本不能同時開兩個 Serial Monitor,請點此下載Tera Term後,點選設定做為第二個Serial Monitor。
使用方法:開啟Tera Term後,點選設定 –>連接埠 –>更改端口與鮑率
Arduino講義:LCD
LCD介紹
目前市面上的 LCD 模組可分文字型及繪圖型兩種。文字型 LCD 模組常見的規格有16 字x1 行,20 字x1 行,40 字x1 行,16 字x2 行,20 字x2 行,40 字x2行等多種。
文字型 LCD 顯示器內部具有字元產生器,因此可以接受 ASCII 字元碼,並將字元顯示在 LCD 上。
LCD架構
I2C 16x2 LCD介紹
LCD接法
學習使用LCD貼出字串
LAB2
LiquidCrystal_I2C:
LAB3
簡易計算機
實驗目標:利用薄膜鍵盤與LCD實現簡易計算機
實驗要求:
code hint:

示範影片:
LAB4
四則運算計算機
實驗目標:利用薄膜鍵盤與LCD實現四則運算計算機
實驗要求:
code hint:

示範影片:
課後問題
Q1.簡述 I2C 如何藉由 SCL 與 SDA 傳送資料 ?
Q2.上課的時候提到可以有多個master,請問若同時有兩個以上的master送出訊號會發生什麼事?並且描述該如何解決。
Q3.電算機為何總和超過 32767 時字串會溢位?如何解決 ?
作業繳交格式
W4結報_第XX組.zip
壓縮檔裡包含:
1.W(週數)結報.pdf
2.資料夾:W(週數)
Lab3.ino
Lab4.ino
*LAB3、LAB4需附上註解