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

Arduino示例代码讲解:Pitch follower 跟随

Arduino示例代码讲解:Pitch follower 跟随

  • Pitch follower
      • 代码功能
      • 代码逐行解释
        • 1. 注释部分
        • 功能:
        • 硬件连接:
        • 2. `setup()` 函数
        • 3. `loop()` 函数
      • 硬件连接
        • **扬声器连接**:
        • **光敏电阻连接**:
        • **Arduino板**:
      • 运行结果
      • 修改建议
    • 视频讲解

Pitch follower

这段代码是一个Arduino示例程序,名为“Pitch follower”,用于根据模拟输入的变化动态调整扬声器发出的音调。

/*
  Pitch follower

 Plays a pitch that changes based on a changing analog input

 circuit:
 * 8-ohm speaker on digital pin 9
 * photoresistor on analog 0 to 5V
 * 4.7K resistor on analog 0 to ground

 created 21 Jan 2010
 modified 31 May 2012
 by Tom Igoe, with suggestion from Michael Flynn

This example code is in the public domain.

 http://arduino.cc/en/Tutorial/Tone2

 */


void setup() {
   
  // initialize serial communications (for debugging only):
  Serial.begin(9600);
}

void loop() {
   
  // read the sensor:
  int sensorReading = analogRead(A0);
  // print the sensor reading so you know its range
  Serial.println(sensorReading);
  // map the analog input range (in this case, 400 - 1000 from the photoresistor)
  // to the output pitch range (120 - 1500Hz)
  // change the minimum 
http://www.dtcms.com/a/80359.html

相关文章:

  • 舞狮表演(dp)
  • 基于32单片机的无人机直流电机闭环调速系统设计
  • xpath轴
  • git 子模块的使用
  • EMQX安装与配置
  • java项目之基于ssm的疫苗预约系统(源码+文档)
  • 基于分类算法的学习失败预警(上)
  • 力扣热题100(方便自己复习,自用)
  • 利用ffmpeg库实现音频Opus编解码
  • 车载以太网网络测试-18【传输层-DOIP协议-1】
  • PyTorch模型转ONNX例子
  • 深入探究 JVM 堆的垃圾回收机制(一)— 判活
  • python3 -m http.sever 8080加载不了解决办法
  • 6个常见的Python设计模式及应用场景
  • Python实战:开发经典猜拳游戏(石头剪刀布)
  • MySQL事务全解析:从概念到实战
  • 【CXX-Qt】2.1.1 为 WebAssembly 构建
  • 汽车免拆诊断案例 | 2024 款路虎发现运动版车无法正常识别智能钥匙
  • Java EE 进阶:MyBatis
  • 【NLP】 11. 神经网络,线性模型,非线性模型,激活函数,感知器优化,正则化学习方法
  • SpringBoot配置文件加载优先级
  • 最大公约数(GCD)和最小公倍数(LCM)专题练习 ——基于罗勇军老师的《蓝桥杯算法入门C/C++》
  • 蓝桥杯2023年第十四届省赛真题-接龙数列
  • Linux后门程序工作原理的详细解释,以及相应的防御措施
  • c语言数据结构 双循环链表设计(完整代码)
  • Ubuntu版免翻墙搭建BatteryHistorian
  • freeswitch(开启抓包信息)
  • 观察RenderDoc截帧UE时“Event”代表什么
  • ssh 多重验证的好处:降低密钥长度,动态密码
  • 分布式任务调度