欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 游戏 > Arduino示例代码讲解:Row-Column Scanning an 8x8 LED matrix with X-Y input LED矩阵

Arduino示例代码讲解:Row-Column Scanning an 8x8 LED matrix with X-Y input LED矩阵

2025/4/18 6:51:36 来源:https://blog.csdn.net/2301_81238088/article/details/147021592  浏览:    关键词:Arduino示例代码讲解:Row-Column Scanning an 8x8 LED matrix with X-Y input LED矩阵

Arduino示例代码讲解:Row-Column Scanning an 8x8 LED matrix with X-Y input LED矩阵

  • Row-Column Scanning an 8x8 LED matrix with X-Y input LED矩阵
    • 功能概述
        • 硬件部分:
        • 软件部分:
    • 代码逐行解释
        • 定义常量
        • 定义变量
        • `setup()` 函数
        • `loop()` 函数
        • `readSensors()` 函数
        • `refreshScreen()` 函数
    • 工作原理

Row-Column Scanning an 8x8 LED matrix with X-Y input LED矩阵

这段代码是一个Arduino示例程序,用于通过行-列扫描控制一个8x8的LED矩阵。它使用两个模拟输入(例如电位器)来控制光标的位置,并在LED矩阵上显示光标的位置。

/*Row-Column Scanning an 8x8 LED matrix with X-Y inputThis example controls an 8x8 LED matrix using two analog inputscreated 27 May 2009modified 30 Aug 2011by Tom IgoeThis example works for the Lumex  LDM-24488NI Matrix. Seehttp://sigma.octopart.com/140413/datasheet/Lumex-LDM-24488NI.pdffor the pin connectionsFor other LED cathode column matrixes, you should only need to changethe pin numbers in the row[] and column[] arraysrows are the anodescols are the cathodes---------Pin numbers:Matrix:* Digital pins 2 through 13,* analog pins 2 through 5 used as digital 16 through 19Potentiometers:* center pins are attached to analog pins 0 and 1, respectively* side pins attached to +5V and ground, respectively.This example code is in the public domain.http://www.arduino.cc/en/Tutorial/RowColumnScanningsee also http://www.tigoe.net/pcomp/code/category/arduinowiring/514 for more*/// 2-dimensional array of row pin numbers:
const int row[8] = {2, 7, 19, 5, 13, 18, 12, 16
};// 2-dimensional array of column pin numbers:
const int col[8] = {6, 11, 10, 3, 17, 4, 8, 9
};// 2-dimensional array of pixels:
int pixels[8][8];// cursor position:
int x = 5;
int y = 5;void setup() {// initialize the I/O pins as outputs// iterate over the pins:for (int thisPin = 0; thisPin < 8; thisPin++) {// initialize the output pins:pinMode(col[thisPin], OUTPUT);pinMode(row[thisPin], OUTPUT);// take the col pins (i.e. the cathodes) high to ensure that// the LEDS are off:digitalWrite(col[thisPin], HIGH);}// initialize the pixel matrix:f

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词