久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
樓主: eagler8
打印 上一主題 下一主題
收起左側

【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)

  [復制鏈接]
2001#
ID:513258 發表于 2019-8-30 19:15 | 只看該作者
RC522模塊各引腳功能
  SDA -- 串行數據線(IIC接口時的I/O線);在SPI接口中為NSS(從機標志管腳);
  SCK -- 連接MCU的SCK信號;
MOSI -- MCU輸出,RC522接收(即主設備輸出,從設備輸入);
MISO -- RC522輸出,MCU接收(即從設備輸出,主設備輸入);
  IRQ -- 中斷請求輸出;
GND -- 接地;
  RST -- 復位;
3.3V -- VSS,工作電壓,若使用的事5V的MCU,注意分壓。



回復

使用道具 舉報

2002#
ID:513258 發表于 2019-8-30 20:36 | 只看該作者





回復

使用道具 舉報

2003#
ID:513258 發表于 2019-8-30 21:04 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百零二:MFRC-522 RFID射頻 IC卡感應模塊讀卡器S50復旦卡鑰匙扣
  4. 1、工具-管理庫-搜索“MFRC522”庫-安裝
  5. 2、項目:使用MFRC522 RFID和Arduino讀寫標簽
  6. 3、RFID與Arduino Uno的連線
  7. SDA------------------------Digital 10
  8. SCK------------------------Digital 13
  9. MOSI----------------------Digital 11
  10. MISO----------------------Digital 12
  11. IRQ------------------------不用連接
  12. GND-----------------------GND
  13. RST------------------------Digital 9                    
  14. 3.3V------------------------3.3V (千萬不要連接到5V接口!!!)
  15. */

  16. #include <SPI.h>
  17. #include <MFRC522.h>

  18. #define SS_PIN 10
  19. #define RST_PIN 9
  20. MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance.

  21. void setup() {
  22.   Serial.begin(9600); // Initialize serial communications with the PC
  23.   SPI.begin();  // Init SPI bus
  24.   mfrc522.PCD_Init(); // Init MFRC522 card
  25.   Serial.println("Scan PICC to see UID and type...");
  26. }

  27. void loop() {
  28.   // Look for new cards
  29.   if ( ! mfrc522.PICC_IsNewCardPresent()) {
  30.     return;
  31.   }

  32.   // Select one of the cards
  33.   if ( ! mfrc522.PICC_ReadCardSerial()) {
  34.     return;
  35.   }

  36.   // Dump debug info about the card. PICC_HaltA() is automatically called.
  37.   mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
  38. }
復制代碼


回復

使用道具 舉報

2004#
ID:513258 發表于 2019-8-30 21:07 | 只看該作者

回復

使用道具 舉報

2005#
ID:513258 發表于 2019-8-30 21:20 | 只看該作者

回復

使用道具 舉報

2006#
ID:513258 發表于 2019-8-31 07:39 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百零二:MFRC-522 RFID射頻 IC卡感應模塊讀卡器S50復旦卡鑰匙扣
  4. 1、工具-管理庫-搜索“MFRC522”庫-安裝
  5. 2、項目二:讀取UID,并將其分別以十進制和十六進制輸出到串口
  6. 3、RFID與Arduino Uno的連線
  7. SDA------------------------Digital 10
  8. SCK------------------------Digital 13
  9. MOSI----------------------Digital 11
  10. MISO----------------------Digital 12
  11. IRQ------------------------不用連接
  12. GND-----------------------GND
  13. RST------------------------Digital 9                    
  14. 3.3V------------------------3.3V (千萬不要連接到5V接口!!!)
  15. */

  16. #include <SPI.h>
  17. #include <MFRC522.h>

  18. #define SS_PIN 10
  19. #define RST_PIN 9

  20. MFRC522 rfid(SS_PIN, RST_PIN); //實例化類

  21. // 初始化數組用于存儲讀取到的NUID
  22. byte nuidPICC[4];

  23. void setup() {
  24.   Serial.begin(9600);
  25.   SPI.begin(); // 初始化SPI總線
  26.   rfid.PCD_Init(); // 初始化 MFRC522
  27. }

  28. void loop() {

  29.   // 找卡
  30.   if ( ! rfid.PICC_IsNewCardPresent())
  31.     return;

  32.   // 驗證NUID是否可讀
  33.   if ( ! rfid.PICC_ReadCardSerial())
  34.     return;

  35.   MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);

  36.   // 檢查是否MIFARE卡類型
  37.   if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI &&  
  38.     piccType != MFRC522::PICC_TYPE_MIFARE_1K &&
  39.     piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
  40.     Serial.println("不支持讀取此卡類型");
  41.     return;
  42.   }
  43.   
  44.   // 將NUID保存到nuidPICC數組
  45.   for (byte i = 0; i < 4; i++) {
  46.     nuidPICC[i] = rfid.uid.uidByte[i];
  47.   }   
  48.   Serial.print("十六進制UID:");
  49.   printHex(rfid.uid.uidByte, rfid.uid.size);
  50.   Serial.println();
  51.   
  52.   Serial.print("十進制UID:");
  53.   printDec(rfid.uid.uidByte, rfid.uid.size);
  54.   Serial.println();
  55.   
  56.   // 使放置在讀卡區的IC卡進入休眠狀態,不再重復讀卡
  57.   rfid.PICC_HaltA();

  58.   // 停止讀卡模塊編碼
  59.   rfid.PCD_StopCrypto1();
  60. }

  61. void printHex(byte *buffer, byte bufferSize) {
  62.   for (byte i = 0; i < bufferSize; i++) {
  63.     Serial.print(buffer[i] < 0x10 ? " 0" : "");
  64.     Serial.print(buffer[i], HEX);
  65.   }
  66. }

  67. void printDec(byte *buffer, byte bufferSize) {
  68.   for (byte i = 0; i < bufferSize; i++) {
  69.     Serial.print(buffer[i] < 0x10 ? " 0" : "");
  70.     Serial.print(buffer[i], DEC);
  71.   }
  72. }
復制代碼


回復

使用道具 舉報

2007#
ID:513258 發表于 2019-8-31 07:44 | 只看該作者

回復

使用道具 舉報

2008#
ID:513258 發表于 2019-8-31 08:10 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百零二:MFRC-522 RFID射頻 IC卡感應模塊讀卡器S50復旦卡鑰匙扣
  4. 1、安裝庫:IDE-工具-管理庫-搜索“MFRC522”庫-安裝
  5. 2、項目三:RC522 模塊的讀寫操作
  6. 3、RFID與Arduino Uno的連線
  7. SDA------------------------Digital 10
  8. SCK------------------------Digital 13
  9. MOSI----------------------Digital 11
  10. MISO----------------------Digital 12
  11. IRQ------------------------不用連接
  12. GND-----------------------GND
  13. RST------------------------Digital 9                    
  14. 3.3V------------------------3.3V (千萬不要連接到5V接口!!!)
  15. */

  16. #include <SPI.h>
  17. #include <MFRC522.h>
  18. #define RST_PIN         9           // 配置針腳
  19. #define SS_PIN          10         
  20. MFRC522 mfrc522(SS_PIN, RST_PIN);   // 創建新的RFID實例
  21. MFRC522::MIFARE_Key key;
  22. void setup() {
  23.     Serial.begin(9600); // 設置串口波特率為9600
  24.     while (!Serial);    // 如果串口沒有打開,則死循環下去不進行下面的操作
  25.     SPI.begin();        // SPI開始
  26.     mfrc522.PCD_Init(); // Init MFRC522 card

  27.     for (byte i = 0; i < 6; i++) {
  28.         key.keyByte[i] = 0xFF;
  29.     }

  30.     Serial.println(F("掃描卡開始進行讀或者寫"));
  31.     Serial.print(F("使用A和B作為鍵"));
  32.     dump_byte_array(key.keyByte, MFRC522::MF_KEY_SIZE);
  33.     Serial.println();
  34.    
  35.     Serial.println(F("注意,會把數據寫入到卡在#1"));
  36. }


  37. void loop() {
  38.     // 尋找新卡
  39.     if ( ! mfrc522.PICC_IsNewCardPresent())
  40.         return;

  41.     // 選擇一張卡
  42.     if ( ! mfrc522.PICC_ReadCardSerial())
  43.         return;

  44.     // 顯示卡片的詳細信息
  45.     Serial.print(F("卡片 UID:"));
  46.     dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
  47.     Serial.println();
  48.     Serial.print(F("卡片類型: "));
  49.     MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
  50.     Serial.println(mfrc522.PICC_GetTypeName(piccType));

  51.     // 檢查兼容性
  52.     if (    piccType != MFRC522::PICC_TYPE_MIFARE_MINI
  53.         &&  piccType != MFRC522::PICC_TYPE_MIFARE_1K
  54.         &&  piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
  55.         Serial.println(F("僅僅適合Mifare Classic卡的讀寫"));
  56.         return;
  57.     }

  58.     // 我們只使用第二個扇區
  59.     // 覆蓋扇區4
  60.     byte sector         = 1;
  61.     byte blockAddr      = 4;
  62.     byte dataBlock[]    = {
  63.         0x01, 0x02, 0x03, 0x04, //  1,  2,   3,  4,
  64.         0x05, 0x06, 0x07, 0x08, //  5,  6,   7,  8,
  65.         0x00, 0x00, 0x00, 0x00, //  0,0,0,0
  66.         0x00, 0x00, 0x00, 0x00  // 0,0,0,0
  67.     };//寫入的數據定義
  68.     byte trailerBlock   = 7;
  69.     MFRC522::StatusCode status;
  70.     byte buffer[18];
  71.     byte size = sizeof(buffer);

  72.     // 原來的數據
  73.     Serial.println(F("顯示原本的數據..."));
  74.     status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &key, &(mfrc522.uid));
  75.     if (status != MFRC522::STATUS_OK) {
  76.         Serial.print(F("身份驗證失敗?或者是卡鏈接失敗"));
  77.         Serial.println(mfrc522.GetStatusCodeName(status));
  78.         return;
  79.     }

  80.     // 顯示整個扇區
  81.     Serial.println(F("顯示所有扇區的數據"));
  82.     mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector);
  83.     Serial.println();

  84.     // 從塊兒讀取數據
  85.     Serial.print(F("讀取塊兒的數據在:")); Serial.print(blockAddr);
  86.     Serial.println(F("塊 ..."));
  87.     status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(blockAddr, buffer, &size);
  88.     if (status != MFRC522::STATUS_OK) {
  89.         Serial.print(F("讀卡失敗,沒有連接上 "));
  90.         Serial.println(mfrc522.GetStatusCodeName(status));
  91.     }
  92.     Serial.print(F("數據內容在第 ")); Serial.print(blockAddr); Serial.println(F(" 塊:"));
  93.     dump_byte_array(buffer, 16); Serial.println();
  94.     Serial.println();

  95.     //開始進行寫入準備
  96.     Serial.println(F("開始進行寫入的準備..."));
  97.     status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_B, trailerBlock, &key, &(mfrc522.uid));
  98.     if (status != MFRC522::STATUS_OK) {
  99.         Serial.print(F("寫入失敗,沒有連接上或者沒有權限 "));
  100.         Serial.println(mfrc522.GetStatusCodeName(status));
  101.         return;
  102.     }

  103.     // Write data to the block
  104.     Serial.print(F("在第: ")); Serial.print(blockAddr);
  105.     Serial.println(F("  塊中寫入數據..."));
  106.     dump_byte_array(dataBlock, 16); Serial.println();
  107.     status = (MFRC522::StatusCode) mfrc522.MIFARE_Write(blockAddr, dataBlock, 16);
  108.     if (status != MFRC522::STATUS_OK) {
  109.         Serial.print(F("寫入失敗... "));
  110.         Serial.println(mfrc522.GetStatusCodeName(status));
  111.     }
  112.     Serial.println();

  113.     // 再次讀取卡中數據,這次是寫入之后的數據
  114.     Serial.print(F("讀取寫入后第")); Serial.print(blockAddr);
  115.     Serial.println(F(" 塊的數據 ..."));
  116.     status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(blockAddr, buffer, &size);
  117.     if (status != MFRC522::STATUS_OK) {
  118.         Serial.print(F("讀取失敗... "));
  119.         Serial.println(mfrc522.GetStatusCodeName(status));
  120.     }
  121.     Serial.print(F("塊 ")); Serial.print(blockAddr); Serial.println(F("數據為 :"));
  122.     dump_byte_array(buffer, 16); Serial.println();
  123.         
  124.     // 驗證一下數據,要保證寫入前后數據是相等的
  125.     // 通過計算塊中的字節數量
  126.     Serial.println(F("等待驗證結果..."));
  127.     byte count = 0;
  128.     for (byte i = 0; i < 16; i++) {
  129.         // 比較一下緩存中的數據(我們讀出來的數據) = (我們剛剛寫的數據)
  130.         if (buffer[i] == dataBlock[i])
  131.             count++;
  132.     }
  133.     Serial.print(F("匹配的字節數量 = ")); Serial.println(count);
  134.     if (count == 16) {
  135.         Serial.println(F("驗證成功 :"));
  136.     } else {
  137.         Serial.println(F("失敗,數據不匹配"));
  138.         Serial.println(F("也許寫入的內容不恰當"));
  139.     }
  140.     Serial.println();
  141.         
  142.     // 轉儲扇區數據
  143.     Serial.println(F("寫入后的數據內容為::"));
  144.     mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector);
  145.     Serial.println();

  146.     // 停止 PICC
  147.     mfrc522.PICC_HaltA();
  148.     //停止加密PCD
  149.     mfrc522.PCD_StopCrypto1();
  150. }

  151. /**
  152. * 將字節數組轉儲為串行的十六進制值
  153. */
  154. void dump_byte_array(byte *buffer, byte bufferSize) {
  155.     for (byte i = 0; i < bufferSize; i++) {
  156.         Serial.print(buffer[i] < 0x10 ? " 0" : " ");
  157.         Serial.print(buffer[i], HEX);
  158.     }
  159. }
復制代碼


回復

使用道具 舉報

2009#
ID:513258 發表于 2019-8-31 08:14 | 只看該作者

回復

使用道具 舉報

2010#
ID:513258 發表于 2019-8-31 11:42 | 只看該作者

回復

使用道具 舉報

2011#
ID:513258 發表于 2019-8-31 11:48 | 只看該作者

回復

使用道具 舉報

2012#
ID:513258 發表于 2019-8-31 11:49 | 只看該作者

回復

使用道具 舉報

2013#
ID:513258 發表于 2019-8-31 11:51 | 只看該作者

回復

使用道具 舉報

2014#
ID:513258 發表于 2019-8-31 11:55 | 只看該作者

回復

使用道具 舉報

2015#
ID:513258 發表于 2019-8-31 11:58 | 只看該作者

回復

使用道具 舉報

2016#
ID:513258 發表于 2019-8-31 12:04 | 只看該作者

回復

使用道具 舉報

2017#
ID:513258 發表于 2019-8-31 12:06 | 只看該作者

回復

使用道具 舉報

2018#
ID:513258 發表于 2019-8-31 12:12 | 只看該作者

回復

使用道具 舉報

2019#
ID:513258 發表于 2019-8-31 13:04 | 只看該作者

NFC Tools PRO
應該是目前為止最強大的NFC工具了吧(APP),可惜nfc這玩意兒不是所有手機都標配。NFC Tools PRO是一款可以讀取和寫入nfc標簽的工具,同時還提供了一些額外功能。NFC工具專業版包含額外的功能,如配置文件管理等等。保存您的標記或任務配置文件后重新使用它們。NFC工具專業版允許您在記錄或任務直接從現有的NFC標簽導入。您可以非常快的編輯您的標簽。您也可以直接運行的任務配置文件。

主要功能:
- 讀寫NFC
- NFC標簽配置文件管理
- 從標簽導入任務

回復

使用道具 舉報

2020#
ID:513258 發表于 2019-8-31 13:10 | 只看該作者
用華為P10手機讀取手頭的IC卡和鑰匙扣相關數據



回復

使用道具 舉報

2021#
ID:513258 發表于 2019-8-31 13:12 | 只看該作者

回復

使用道具 舉報

2022#
ID:513258 發表于 2019-8-31 14:23 | 只看該作者
37款傳感器與模塊的提法,在網絡上廣泛流傳,其實Arduino能夠兼容的傳感器模塊肯定是不止37種的。鑒于本人手頭積累了一些傳感器和模塊,依照實踐出真知(一定要動手做)的理念,以學習和交流為目的,這里準備逐一動手試試做實驗,不管成功與否,都會記錄下來---小小的進步或是搞不定的問題,希望能夠拋磚引玉。

【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
實驗一百零三: 8X32 LED點陣顯示模塊 MAX7219 輸出 共陰 5V 模組





回復

使用道具 舉報

2023#
ID:513258 發表于 2019-8-31 14:36 | 只看該作者


MAX7219
是美國MAXIM 公司推出的多位LED 顯示驅動器,采用3 線串行接口傳送數據,可直接與單片機接口連接,用戶能方便修改其內部參數,以實現多位LED 顯示。它內含硬件動態掃描電路、BCD譯碼器、段驅動器和位驅動器。此外,其內部還含有8X8 位靜態RAM,用于存放8 個數字的顯示數據。顯然,它可直接驅動64 段LED點陣顯示器。當多片MAX7219 級聯時,可控制更多的LED 點陣顯示器。顯示的數據通過單片機數據處理后,送給MAX7219 顯示。

MAX7219/MAX7221是一種集成化的串行輸入/輸出共陰極顯示驅動器,它連接微處理器與8位數字的7段數字LED顯示,也可以連接條線圖顯示器或者64個獨立的LED。其上包括一個片上的B型BCD編碼器、多路掃描回路,段字驅動器,而且還有一個8*8的靜態RAM用來存儲每一個數據。只有一個外部寄存器用來設置各個LED的段電流。MAX7221與SPI™、QSPI™以及 MICROWIRE™相兼容,同時它有限制回轉電流的段驅動來減少EMI(電磁干擾)。一個方便的四線串行接口可以聯接所有通用的微處理器。每個數據可以尋址在更新時不需要改寫所有的顯示。MAX7219/MAX7221同樣允許用戶對每一個數據選擇編碼或者不編碼。整個設備包含一個150μA的低功耗關閉模式,模擬和數字亮度控制,一個掃描限制寄存器允許用戶顯示1-8位數據,還有一個讓所有LED發光的檢測模式。

回復

使用道具 舉報

2024#
ID:513258 發表于 2019-8-31 15:55 | 只看該作者
管腳描述
1 DIN 串行數據輸入端口。在時鐘上升沿時數據被載入內部的16位寄存器。
2,3,5-8,10,11 DIG 0–DIG7 八個數據驅動線路置顯示器共陰極為低電平。關閉時7219此管腳輸出高電平,7221呈現高阻抗。
4,9 GND 地線 (4腳和9腳必須同時接地)
12 LOAD (MAX7219) 載入數據。連續數據的后16位在LOAD端的上升沿時被鎖定。CS (MAX7221) 片選端。該端為低電平時串行數據被載入移位寄存器。連續數據的后
16位在cs端的上升沿時被鎖定。
13 CLK 時鐘序列輸入端。最大速率為 10MHz.在時鐘的上升沿, 數據移入內部移位寄存器。 下降沿時, 數據從DOUT端輸出。對MAX7221來說,只有當cs端為低電平時時鐘輸入才有效。
14-17,20-23 SEG 7 段和小數點驅動,為顯示器提供電流。當一個段驅A–SEG G, 動關閉時,7219的此端呈低電平,7221呈現高阻抗。DP
18 SET 通過一個電阻連接到VDD 來提高段電流。
19 V+ 正極電壓輸入,+5V
24 DOUT 串行數據輸出端口,從DIN輸入的數據在16.5個時鐘周期后在此端有效。當使用多個MAX7219/MAX7221時用此端方便擴展。



回復

使用道具 舉報

2025#
ID:513258 發表于 2019-8-31 16:11 | 只看該作者

功能特點
1 10MHz連續串行口
2 獨立的LED段控制
3 數字的譯碼與非譯碼選擇
4 150μA的低功耗關閉模式
5 亮度的數字和模擬控制
6 高電壓中斷顯示
7 共陰極LED顯示驅動
8 限制回轉電流的段驅動來減少EMI(MAX7221)
9 SPI, QSPI, MICROWIRE串行接口(MAX7221)
10 24腳的 DIP和 SO 封裝

回復

使用道具 舉報

2026#
ID:513258 發表于 2019-8-31 16:46 | 只看該作者


8X32 LED點陣顯示級聯模塊,MAX7219是一種集成化的串行輸入/輸出共陰極顯示驅動器,它連接微處理器與8位數字的7段數字LED顯示,也可以連接條線圖顯示器或者64個獨立的LED。其上包括一個片上的B型BCD編碼器、多路掃描回路,段字驅動器,而且還有一個8*8的靜態RAM用來存儲每一個數據。只有一個外部寄存器用來設置各個LED的段電流。一個方便的四線串行接口可以聯接所有通用的微處理器。每個數據可以尋址在更新時不需要改寫所有的顯示。MAX7219同樣允許用戶對每一個數據選擇編碼或者不編碼。整個設備包含一個150μA的低功耗關閉模式,模擬和數字亮度控制,一個掃描限制寄存器允許用戶顯示1-8位數據,還有一個讓所有LED發光的檢測模式。只需要3個IO口即可驅動1個點陣!點陣顯示時無閃爍!支持級聯!



回復

使用道具 舉報

2027#
ID:513258 發表于 2019-9-2 12:01 | 只看該作者




回復

使用道具 舉報

2028#
ID:513258 發表于 2019-9-2 12:27 | 只看該作者

回復

使用道具 舉報

2029#
ID:513258 發表于 2019-9-2 12:30 | 只看該作者

回復

使用道具 舉報

2030#
ID:513258 發表于 2019-9-2 12:32 | 只看該作者


模塊參數:
1.單個模塊可以驅動一個8*8共陰點陣
2.模塊工作電壓:5V
3.模塊尺寸:長12.8厘米X寬3.2厘米X高1.3厘米
4.帶64個固定螺絲孔,孔徑3mm
5.模塊帶輸入輸出接口,支持多個模塊級聯

接線說明:
1.模塊左邊為輸入端口,右邊為輸出端口。
2.控制單個模塊時,只需要將輸入端口接到CPU
3.多個模塊級聯時,第1個模塊的輸入端接CPU,輸出端接第2個模塊的輸入端,第2個模塊的輸出端接第3個模塊的輸入端,以此類推...

回復

使用道具 舉報

2031#
ID:513258 發表于 2019-9-2 12:38 | 只看該作者

回復

使用道具 舉報

2032#
ID:513258 發表于 2019-9-2 12:39 | 只看該作者

回復

使用道具 舉報

2033#
ID:513258 發表于 2019-9-2 12:40 | 只看該作者

回復

使用道具 舉報

2034#
ID:513258 發表于 2019-9-2 12:47 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百零三: 8X32 LED點陣顯示級聯模塊 MAX7219 輸出 共陰 5V 模組
  4. 1、下載安裝庫:
  5. GitHub | riyas-org/max7219  https://github.com/riyas-org/max7219
  6. 2、項目:應用多種函數,顯示字母,笑臉等圖案以及左向移動
  7. 3、連線:
  8. VCC  →  5V
  9. GND  →  GND
  10. DIN  →  D11
  11. CS   →  D12
  12. CLK  →  D13
  13. */

  14. #include <MaxMatrix.h>
  15. int DIN = 11;   // DIN pin of MAX7219 module
  16. int CLK = 13;   // CLK pin of MAX7219 module
  17. int CS  = 12;    // CS pin of MAX7219 module
  18. int maxInUse = 1;
  19. MaxMatrix m(DIN, CS, CLK, maxInUse);
  20. char A[] = {4, 8,
  21.             B01111110,
  22.             B00010001,
  23.             B00010001,
  24.             B01111110,
  25.            };
  26. char B[] = {4, 8,
  27.             B01111111,
  28.             B01001001,
  29.             B01001001,
  30.             B00110110,
  31.            };
  32. char smile01[] = {8, 8,
  33.                   B00111100,
  34.                   B01000010,
  35.                   B10010101,
  36.                   B10100001,
  37.                   B10100001,
  38.                   B10010101,
  39.                   B01000010,
  40.                   B00111100
  41.                  };
  42. char smile02[] = {8, 8,
  43.                   B00111100,
  44.                   B01000010,
  45.                   B10010101,
  46.                   B10010001,
  47.                   B10010001,
  48.                   B10010101,
  49.                   B01000010,
  50.                   B00111100
  51.                  };
  52. char smile03[] = {8, 8,
  53.                   B00111100,
  54.                   B01000010,
  55.                   B10100101,
  56.                   B10010001,
  57.                   B10010001,
  58.                   B10100101,
  59.                   B01000010,
  60.                   B00111100
  61.                  };
  62. void setup() {
  63.   m.init(); // MAX7219 initialization
  64.   m.setIntensity(8); // initial led matrix intensity, 0-15
  65. }
  66. void loop() {
  67.   // Seting the LEDs On or Off at x,y or row,column position
  68.   m.setDot(6,2,true);
  69.   delay(1000);
  70.   m.setDot(6,3,true);
  71.   delay(1000);
  72.   m.clear(); // Clears the display
  73.   for (int i=0; i<8; i++){
  74.     m.setDot(i,i,true);
  75.     delay(300);
  76.   }
  77.   m.clear();
  78.   // Displaying the character at x,y (upper left corner of the character)  
  79.   m.writeSprite(2, 0, A);
  80.   delay(1000);
  81.   m.writeSprite(2, 0, B);
  82.   delay(1000);
  83.   m.writeSprite(0, 0, smile01);
  84.   delay(1000);
  85.   
  86.   m.writeSprite(0, 0, smile02);
  87.   delay(1000);
  88.   
  89.   m.writeSprite(0, 0, smile03);
  90.   delay(1000);
  91.   
  92.   for (int i=0; i<8; i++){
  93.     m.shiftLeft(false,false);
  94.     delay(300);
  95.   }
  96.   m.clear();
  97. }
復制代碼


回復

使用道具 舉報

2035#
ID:513258 發表于 2019-9-2 14:57 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百零三: 8X32 LED點陣顯示級聯模塊 MAX7219 輸出 共陰 5V 模組
  4. 1、下載安裝庫:
  5. GitHub | riyas-org/max7219  https://github.com/riyas-org/max7219
  6. 2、項目:程序中將所要顯示的圖型使用數組方式存放,主回圈中交錯顯示在 8x8 點陣
  7. 模塊上產生一個有趣的點陣動畫
  8. 3、連線:
  9. VCC  →  5V
  10. GND  →  GND
  11. DIN 接 D11 (MOSI)
  12. CS  接 D10 (SS)
  13. CLK 接 D13 (SCK)
  14. */

  15. #include <SPI.h>

  16. const byte sprite[2][8] = {
  17.     { 0xf8, 0xbc, 0x15, 0x7e, 0x7e, 0x15, 0xbc, 0xf8 },  
  18.     { 0xfc, 0x8e, 0x1b, 0x2e, 0x2e, 0x1b, 0x8e, 0xfc }   
  19. };

  20. const byte DECODEMODE = 0x09;
  21. const byte INTENSITY = 0x0a;
  22. const byte SCANLIMIT = 0x0b;
  23. const byte SHUTDOWN = 0x0c;
  24. const byte DISPLAYTEST = 0x0f;

  25. void max7219(const byte reg, const byte data) {
  26.   digitalWrite(SS, LOW);
  27.   SPI.transfer(reg);
  28.   SPI.transfer(data);
  29.   digitalWrite(SS, HIGH);  
  30. }

  31. void setup() {
  32.   SPI.begin();
  33.   
  34.   max7219(SCANLIMIT, 7);
  35.   max7219(DECODEMODE, 0);
  36.   max7219(INTENSITY, 2);
  37.   max7219(DISPLAYTEST, 0);
  38.   max7219(SHUTDOWN, 1);  
  39.   
  40.   for(byte i=0; i<8; i++) {
  41.     max7219(i+1, 0);
  42.   }
  43. }  

  44. void loop() {
  45.   for(byte j=0; j<2; j++) {
  46.     for(byte i=0; i<8; i++) {
  47.       max7219(i+1, sprite[j][i]);
  48.     }
  49.   delay(500);
  50.   }
  51. }
復制代碼


回復

使用道具 舉報

2036#
ID:513258 發表于 2019-9-2 15:32 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百零三: 8X32 LED點陣顯示級聯模塊 MAX7219 輸出 共陰 5V 模組
  4. 1、下載庫 https://www.pjrc.com/teensy/arduino_libraries/Matrix_Sprite.zip
  5. 2、項目:在四個8x8屏間跳動的紅點
  6. 3、連線:
  7. VCC  →  5V
  8. GND  →  GND
  9. DIN 接 D11 (MOSI)
  10. CS  接 D10 (SS)
  11. CLK 接 D13 (SCK)
  12. */

  13. #include <Sprite.h>  // Sprite before Matrix
  14. #include <Matrix.h>

  15. const int numChips = 4;

  16. //DIN, CLK, SS, #chips
  17. Matrix myLeds = Matrix(11, 13, 10, numChips);

  18. void setup() {
  19.   myLeds.clear();
  20. }

  21. void loop() {
  22.   byte x, y;

  23.   // light one LED at a time, scanning left to right
  24.   // and top to bottom... useful for testing the matrix
  25.   for (y=0; y<8; y++) {
  26.     for (x=0; x<(numChips * 8); x++) {
  27.       myLeds.write(x, y, HIGH);
  28.       delay(20);
  29.       myLeds.write(x, y, LOW);
  30.     }
  31.   }
  32. }
復制代碼


回復

使用道具 舉報

2037#
ID:513258 發表于 2019-9-2 16:14 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百零三: 8X32 LED點陣顯示級聯模塊 MAX7219 輸出 共陰 5V 模組
  4. 1、下載庫 https://www.pjrc.com/teensy/arduino_libraries/Matrix_Sprite.zip
  5. 2、項目:顯示字母
  6. 3、連線:
  7. VCC  →  5V
  8. GND  →  GND
  9. DIN 接 D11 (MOSI)
  10. CS  接 D10 (SS)
  11. CLK 接 D13 (SCK)
  12. */

  13. #include <Sprite.h>  // Sprite before Matrix
  14. #include <Matrix.h>

  15. //DIN, CLK, CS, #chips
  16. Matrix myLeds = Matrix(11, 13, 10, 3);

  17. Sprite letter_L = Sprite(5, 8,
  18.   B11000,
  19.   B11000,
  20.   B11000,
  21.   B11000,
  22.   B11000,
  23.   B11000,
  24.   B11111,
  25.   B11111
  26. );
  27. Sprite letter_E = Sprite(5, 8,
  28.   B11111,
  29.   B11111,
  30.   B11000,
  31.   B11110,
  32.   B11110,
  33.   B11000,
  34.   B11111,
  35.   B11111
  36. );
  37. Sprite letter_D = Sprite(6, 8,
  38.   B111100,
  39.   B111110,
  40.   B110111,
  41.   B110011,
  42.   B110011,
  43.   B110111,
  44.   B111110,
  45.   B111100
  46. );
  47. Sprite letter_S = Sprite(5, 8,
  48.   B01110,
  49.   B11111,
  50.   B11000,
  51.   B11110,
  52.   B01111,
  53.   B00011,
  54.   B11111,
  55.   B01110
  56. );

  57. void setup() {
  58.   myLeds.clear();
  59.   myLeds.setBrightness(0);
  60.   myLeds.write(3, 0, letter_L);
  61.   myLeds.write(10, 0, letter_E);
  62.   myLeds.write(18, 0, letter_D);
  63.   myLeds.write(26, 0, letter_S);
  64. }

  65. void loop() {
  66. }
復制代碼


回復

使用道具 舉報

2038#
ID:513258 發表于 2019-9-2 16:17 | 只看該作者

回復

使用道具 舉報

2039#
ID:513258 發表于 2019-9-2 16:24 | 只看該作者
Matrix庫的幾個函數

基本用法,僅限像素
Matrix myLeds = Matrix(DIN,CLK,LOAD,numChips);
使用您選擇的名稱創建Matrix對象的實例。DIN,CLK和LOAD是連接這些信號的引腳號。如果連接了多個單獨連接的MAX7219芯片,則可以創建多個對象。

myLeds。clear();
清除整個顯示屏。

myLeds。setBrightness(15);
設置顯示亮度,從0到15(最亮)。

myLeds。write(x,y,value);
更改單個像素。對于關閉,值應為LOW,對于on,值應為HIGH。

基本用法,使用Sprite
Sprite myIcon = Sprite(寬度,高度,B11000,B11000,B11111,B11111);
創建一個精靈對象。您可以根據需要創建任意數量的精靈,每個精靈都有一個唯一的名稱。寬度應與每個數據值中的位數匹配,高度應與數據值的數量匹配。

myLeds。write(x,y,myIcon);
在顯示屏上繪制一個閃爍的精靈。

回復

使用道具 舉報

2040#
ID:513258 發表于 2019-9-2 16:52 | 只看該作者
  1. /*
  2. 【Arduino】108種傳感器模塊系列實驗(資料+代碼+圖形+仿真)
  3. 實驗一百零三: 8X32 LED點陣顯示級聯模塊 MAX7219 輸出 共陰 5V 模組
  4. 1、下載安裝庫:
  5. GitHub | riyas-org/max7219  https://github.com/riyas-org/max7219
  6. 2、項目:建立字母庫,立式滾動文本顯示
  7. 3、連線:
  8. VCC  →  5V
  9. GND  →  GND
  10. DIN 接 D11 (MOSI)
  11. CS  接 D10 (SS)
  12. CLK 接 D13 (SCK)
  13. */

  14. #include <MaxMatrix.h>
  15. #include <avr/pgmspace.h>
  16. PROGMEM const unsigned char CH[] = {
  17.   3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space
  18.   1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // !
  19.   3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // "
  20.   5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // #
  21.   4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $
  22.   5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // %
  23.   5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // &
  24.   1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // '
  25.   3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // (
  26.   3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // )
  27.   5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // *
  28.   5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // +
  29.   2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // ,
  30.   4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // -
  31.   2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // .
  32.   4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // /
  33.   4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0
  34.   3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1
  35.   4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2
  36.   4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3
  37.   4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4
  38.   4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5
  39.   4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6
  40.   4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7
  41.   4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8
  42.   4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9
  43.   2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // :
  44.   2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ;
  45.   3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // <
  46.   3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // =
  47.   3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // >
  48.   4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ?
  49.   5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @
  50.   4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A
  51.   4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B
  52.   4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C
  53.   4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D
  54.   4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E
  55.   4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F
  56.   4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G
  57.   4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H
  58.   3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I
  59.   4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J
  60.   4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K
  61.   4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L
  62.   5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M
  63.   5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N
  64.   4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O
  65.   4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P
  66.   4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q
  67.   4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R
  68.   4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S
  69.   5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T
  70.   4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U
  71.   5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V
  72.   5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W
  73.   5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X
  74.   5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y
  75.   4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z
  76.   2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [
  77.   4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash
  78.   2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ]
  79.   3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat
  80.   4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _
  81.   2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // `
  82.   4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a
  83.   4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b
  84.   4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c
  85.   4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d
  86.   4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e
  87.   3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f
  88.   4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g
  89.   4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h
  90.   3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i
  91.   4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j
  92.   4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k
  93.   3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l
  94.   5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m
  95.   4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n
  96.   4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o
  97.   4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p
  98.   4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q
  99.   4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r
  100.   4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s
  101.   3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t
  102.   4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u
  103.   5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v
  104.   5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w
  105.   5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x
  106.   4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y
  107.   3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z
  108.   3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // {
  109.   1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // |
  110.   3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // }
  111.   4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~
  112. };
  113. int DIN = 11;   // DIN pin of MAX7219 module
  114. int CLK = 13;   // CLK pin of MAX7219 module
  115. int CS = 10;    // CS pin of MAX7219 module
  116. int maxInUse = 4;
  117. MaxMatrix m(DIN, CS, CLK, maxInUse);
  118. byte buffer[10];
  119. char text[]= "Hello Eagler8"; // Scrolling text
  120. void setup() {
  121.   m.init(); // module initialize
  122.   m.setIntensity(0); // dot matix intensity 0-15
  123. }
  124. void loop() {
  125.   printStringWithShift(text, 100); // (text, scrolling speed)
  126. }
  127. // Display=the extracted characters with scrolling
  128. void printCharWithShift(char c, int shift_speed) {
  129.   if (c < 32) return;
  130.   c -= 32;
  131.   memcpy_P(buffer, CH + 7 * c, 7);
  132.   m.writeSprite(32, 0, buffer);
  133.   m.setColumn(32 + buffer[0], 0);
  134.   for (int i = 0; i < buffer[0] + 1; i++)
  135.   {
  136.     delay(shift_speed);
  137.     m.shiftLeft(false, false);
  138.   }
  139. }
  140. // Extract the characters from the text string
  141. void printStringWithShift(char* s, int shift_speed) {
  142.   while (*s != 0) {
  143.     printCharWithShift(*s, shift_speed);
  144.     s++;
  145.   }
  146. }
復制代碼


回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 精品成人 | 国产精品揄拍一区二区 | 91伊人| 欧美精品一区三区 | 精品不卡| 精品国产一区二区国模嫣然 | 午夜免费观看网站 | 欧美一级免费片 | 日韩视频在线免费观看 | 久久久久成人精品 | 四虎影院新网址 | www国产成人免费观看视频,深夜成人网 | 中文字幕在线精品 | 午夜精品一区二区三区在线观看 | 日本a视频 | 在线看片网站 | 欧美日韩中文字幕在线播放 | 久久精品91 | 亚洲精品欧美一区二区三区 | 免费在线观看黄色av | 国产一级免费在线观看 | 欧美不卡视频一区发布 | 日韩av成人 | 91精品国产91久久久久久最新 | 欧美日韩亚洲国产 | 国产美女在线看 | 涩涩视频在线观看 | 免费视频成人国产精品网站 | 日本a网站 | 成人做爰69片免费观看 | 羞羞视频在线观看 | 国产91九色 | 久久久久久www | 日日操夜夜操视频 | 成人三级视频 | 欧美日韩一区在线 | 久久亚洲一区二区 | 日韩精品一区二区在线 | 国产精品国产精品国产专区不卡 | 亚洲网站在线播放 | 日日操夜夜操天天操 |