4166| 1
|
[项目] 光控特雷门琴 |
http://fanyapbl.chaoxing.com/pbl/bbs/preview?dataId=158137 void setup() { // 初始化串口连接(调试用): Serial.begin(9600); } void loop() { // 读取传感器值: int sensorReading = analogRead(A0); //打印一下传感器的值来找到范围: Serial.println(sensorReading);// 将模拟输入值的对应到 120-1500HZ 的声音 int thisPitch = map(sensorReading, 100, 1000, 20, 20000); // 播放音符: tone(9, thisPitch, 10); delay(1); } |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed