Arduino--二维码显示
生活随笔
收集整理的這篇文章主要介紹了
Arduino--二维码显示
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
(1)簡介
隨著數字化發展,二維碼在生活中的使用率越來越高,本文就基于Arduino控制器生成二維碼并在液晶屏幕上顯示出來,掃描后會跳轉到指定的網頁,二維碼的顯示內容可任意修改。
本文使用0.96寸OLED液晶顯示屏,如下圖所示:
(2)接線
Arduino控制器使用的是UNO,0.96寸OLED液晶顯示屏使用的是IIC接口,接線方式如下表所示:
| VCC | 5V |
| GND | GND |
| SCL | A5 |
| SDA | A4 |
(3)主程序(完整代碼及函數頭文件見文末鏈接)
qrcode_initText(&qrcode, qrcodeData, 3 , ECC_LOW, "https://www.baidu.com");// start drawu8g2.firstPage();do {// get the draw starting point,128 and 64 is screen sizeuint8_t x0 = (128 - qrcode.size * 2) / 2;uint8_t y0 = (64 - qrcode.size * 2) / 2;// get QR code pixels in a loopfor (uint8_t y = 0; y < qrcode.size; y++) {for (uint8_t x = 0; x < qrcode.size; x++) {// Check this point is black or whiteif (qrcode_getModule(&qrcode, x, y)) {u8g2.setColorIndex(1);} else {u8g2.setColorIndex(0);}// Double the QR code pixelsu8g2.drawPixel(x0 + x * 2, y0 + y * 2);u8g2.drawPixel(x0 + 1 + x * 2, y0 + y * 2);u8g2.drawPixel(x0 + x * 2, y0 + 1 + y * 2);u8g2.drawPixel(x0 + 1 + x * 2, y0 + 1 + y * 2);}}} while ( u8g2.nextPage() );(4)結果展示
Arduino 二維碼顯示
完整代碼鏈接:
CSDN下載
https://download.csdn.net/download/u011816009/85086775
百度網盤下載
https://pan.baidu.com/s/1ZBKVnUjwMuV9iGCcO1e33w
提取碼:ypae
總結
以上是生活随笔為你收集整理的Arduino--二维码显示的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Arduino--ESP8266物联网W
- 下一篇: Altium designer--变压器