当前位置: 首页 > news >正文

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 input

 This example controls an 8x8 LED matrix using two analog inputs

 created 27 May 2009
 modified 30 Aug 2011
 by Tom Igoe

 This example works for the Lumex  LDM-24488NI Matrix. See
 http://sigma.octopart.com/140413/datasheet/Lumex-LDM-24488NI.pdf
 for the pin connections

 For other LED cathode column matrixes, you should only need to change
 the pin numbers in the row[] and column[] arrays

 rows are the anodes
 cols are the cathodes
 ---------

 Pin numbers:
 Matrix:
 * Digital pins 2 through 13,
 * analog pins 2 through 5 used as digital 16 through 19
 Potentiometers:
 * 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/RowColumnScanning

 see 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

相关文章:

  • 提升工作效率的可视化笔记应用程序
  • HTML表单属性2
  • Nginx 生产配置文件
  • anomalib—2—输入图像大小调整
  • 28--当路由器开始“宫斗“:设备控制面安全配置全解
  • 鸿蒙开发04界面渲染
  • JavaScript promise实例——通过XHR获取省份列表
  • 4-c语言中的数据类型
  • OSCP - HTB - BoardLight
  • 网络钓鱼攻击的威胁和执法部门的作用(第二部分)
  • TensorRT 有什么特殊之处
  • LLM 部署(1)——LLM 部署框架对比
  • 开源身份和访问管理方案之keycloak(三)keycloak健康检查(k8s)
  • ollama更新升级及警告解决
  • 过孔的载流能力
  • 深度解析需求分析:理论、流程与实践
  • 2011-2019年各省地方财政金融监管支出数据
  • 个人博客系统——测试报告
  • Spring 中的 BeanFactory 和 ApplicationContext
  • V-SHOW和箭头函数在VUE项目的踩坑点
  • 必须做网站等级保护/站长之家综合查询工具
  • wordpress 新建php页面/南昌seo排名收费
  • 店铺网站怎么建/武汉做网页推广公司
  • 佛山格尔做网站的公司/网页做推广
  • 南京app开发公司定制/搜索引擎优化解释
  • 郑州网站建设国奥大厦/国内seo服务商