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

【Arduino24】8*8点阵实验

硬件准备

8*8点阵:1个

旋钮电位器:1个

面包板:1块

杜邦线:若干

硬件连线

软件程序

//定义引脚
#define xKnob_pin A0  //x轴旋钮的引脚
#define yKnob_pin A1  //y轴旋钮的引脚
const int row_pin[8] = { 6, 11, 10, 3, 17, 4, 8, 9 };    // 行引脚对应的数组
const int col_pin[8] = { 2, 7, 19, 5, 13, 18, 12, 16 };  // 列引脚对应的数组int pixels[8][8];                                        // 点阵对应的数组//定义变量
unsigned int x_val = -1;//x轴变量
unsigned int y_val = -1;//函数声明
void Init();
void display();
void test();void setup() {Serial.begin(9600);for (int thisRow = 0; thisRow < 8; thisRow++) {pinMode(row_pin[thisRow], OUTPUT);     //设置行引脚为输出模式digitalWrite(row_pin[thisRow], LOW);  //行引脚输出低电平}for (int thisCol = 0; thisCol < 8; thisCol++) {pinMode(col_pin[thisCol], OUTPUT);    //设置列引脚为输出模式digitalWrite(col_pin[thisCol], HIGH);  //列引脚输出高电平}
}void loop() {Init();display();//test();
}void Init(){for (int thisRow = 0; thisRow < 8; thisRow++) {digitalWrite(row_pin[thisRow], LOW);  //行引脚输出低电平}for (int thisCol = 0; thisCol < 8; thisCol++) {digitalWrite(col_pin[thisCol], HIGH);  //列引脚输出高电平}
}void display(){//读取旋钮模拟值,映射为0~7x_val = map(analogRead(xKnob_pin),0,1023,0,7);y_val = map(analogRead(yKnob_pin),0,1023,0,7);Serial.print("x ");Serial.println(x_val);Serial.print("y ");Serial.println(y_val);//根据模拟值决定哪行哪列亮digitalWrite(col_pin[y_val], LOW);digitalWrite(row_pin[x_val], HIGH);
}void test() {for (int thisCol = 0; thisCol < 8; thisCol++) {digitalWrite(col_pin[thisCol], LOW);  //列引脚输出低电平for (int thisRow = 0; thisRow < 8; thisRow++) {digitalWrite(row_pin[thisRow], HIGH);  delay(500);digitalWrite(row_pin[thisRow], LOW);  }digitalWrite(col_pin[thisCol], HIGH);  //列引脚输出高电平}
}

产品展示视频

【Arduino24】88点阵

总结

通过本次实验,我学会了8*8点阵的使用,并复习了旋钮电位器的知识。

http://www.lryc.cn/news/157055.html

相关文章:

  • 2023年09月数据库流行度最新排名
  • jenkins快速跑通helloworld任务
  • win10中安装ros
  • 问道管理:光刻胶概念再度活跃,广信材料两连板,蓝英装备等涨停
  • InstructPix2Pix(CVPR2023)-图像编辑论文解读
  • 基于神经网络结合紫外差分光谱的二氧化硫浓度定量预测
  • 一个新工具 nolyfill
  • vue的第2篇 开发环境vscode的安装以及创建项目空间
  • Java之包装类的详细解析
  • SpringBoot项目防止接口重复提交(简单拦截器实现方案)
  • C语言 数据结构与算法 I
  • PHP指定时间戳/日期加一天,一年,一周,一月
  • 前端框架 vue-admin-template的搭建运行
  • Git—版本控制系统
  • 【MySQL基础|第一篇】——谈谈SQL中的DDL语句
  • 移动安全测试框架-MobSF WINDOWS 环境搭建
  • QT连接OpenCV库完成人脸识别
  • 使用 ElasticSearch 作为知识库,存储向量及相似性搜索
  • 视频图像处理算法opencv在esp32及esp32s3上面的移植,也可以移植openmv
  • 2. postgresql并行扫描(1)——pg强制走并行扫描建表及参数配置
  • 【C++】动态内存管理
  • MATLAB R2023a完美激活版(附激活补丁)
  • 垃圾回收 - 标记压缩算法
  • Vue中过滤器如何使用?
  • 【爬虫】7.4. 字体反爬案例分析与爬取实战
  • Linux cat 的作用
  • Windows中的命令行提示符里的Start命令执行路径包含空格时的问题
  • 【基础计算机网络1】认识计算机网络体系结构,了解计算机网络的大致模型(上)
  • 学校宿舍智能水电表管理系统:为节约资源保驾护航
  • EasyFalsh移植使用方法