码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 【Arduino24】8*8点阵实验


    硬件准备

    8*8点阵:1个

    旋钮电位器:1个

    面包板:1块

    杜邦线:若干

    硬件连线

    软件程序

    1. //定义引脚
    2. #define xKnob_pin A0 //x轴旋钮的引脚
    3. #define yKnob_pin A1 //y轴旋钮的引脚
    4. const int row_pin[8] = { 6, 11, 10, 3, 17, 4, 8, 9 }; // 行引脚对应的数组
    5. const int col_pin[8] = { 2, 7, 19, 5, 13, 18, 12, 16 }; // 列引脚对应的数组
    6. int pixels[8][8]; // 点阵对应的数组
    7. //定义变量
    8. unsigned int x_val = -1;//x轴变量
    9. unsigned int y_val = -1;
    10. //函数声明
    11. void Init();
    12. void display();
    13. void test();
    14. void setup() {
    15. Serial.begin(9600);
    16. for (int thisRow = 0; thisRow < 8; thisRow++) {
    17. pinMode(row_pin[thisRow], OUTPUT); //设置行引脚为输出模式
    18. digitalWrite(row_pin[thisRow], LOW); //行引脚输出低电平
    19. }
    20. for (int thisCol = 0; thisCol < 8; thisCol++) {
    21. pinMode(col_pin[thisCol], OUTPUT); //设置列引脚为输出模式
    22. digitalWrite(col_pin[thisCol], HIGH); //列引脚输出高电平
    23. }
    24. }
    25. void loop() {
    26. Init();
    27. display();
    28. //test();
    29. }
    30. void Init(){
    31. for (int thisRow = 0; thisRow < 8; thisRow++) {
    32. digitalWrite(row_pin[thisRow], LOW); //行引脚输出低电平
    33. }
    34. for (int thisCol = 0; thisCol < 8; thisCol++) {
    35. digitalWrite(col_pin[thisCol], HIGH); //列引脚输出高电平
    36. }
    37. }
    38. void display(){
    39. //读取旋钮模拟值,映射为0~7
    40. x_val = map(analogRead(xKnob_pin),0,1023,0,7);
    41. y_val = map(analogRead(yKnob_pin),0,1023,0,7);
    42. Serial.print("x ");
    43. Serial.println(x_val);
    44. Serial.print("y ");
    45. Serial.println(y_val);
    46. //根据模拟值决定哪行哪列亮
    47. digitalWrite(col_pin[y_val], LOW);
    48. digitalWrite(row_pin[x_val], HIGH);
    49. }
    50. void test() {
    51. for (int thisCol = 0; thisCol < 8; thisCol++) {
    52. digitalWrite(col_pin[thisCol], LOW); //列引脚输出低电平
    53. for (int thisRow = 0; thisRow < 8; thisRow++) {
    54. digitalWrite(row_pin[thisRow], HIGH);
    55. delay(500);
    56. digitalWrite(row_pin[thisRow], LOW);
    57. }
    58. digitalWrite(col_pin[thisCol], HIGH); //列引脚输出高电平
    59. }
    60. }

    产品展示视频

    【Arduino24】88点阵

    总结

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

  • 相关阅读:
    Java 基于 SpringBoot+Vue 的留守儿童关爱网站
    软件安全测试
    数据结构题目收录(二十五)
    凉鞋的 Unity 笔记 109. 专题一 小结
    react-router@6 版本初体验
    哺乳期间宝妈有些东西不能吃,吃了会影响宝宝
    【Spring Cloud】如何确定微服务项目的Spring Boot、Spring Cloud、Spring Cloud Alibaba的版本
    【计算机毕业设计】092基于微信小程序二手闲置交易市场
    python-opencv之形态学操作(腐蚀和膨胀)原理详解
    StarRocks从入门到精通系列三:创建表和导入和查询数据
  • 原文地址:https://blog.csdn.net/m0_65960610/article/details/132720279
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号