极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 30795|回复: 12

新手ARDUINO 电容感应钢琴制作((求救

[复制链接]
发表于 2019-9-6 07:52:57 | 显示全部楼层 |阅读模式
第一次摸这个东西。然后跟了2个教程实验了无数次都没有成功。。。。
不知道是我做错了什么吗?

教程1:
arduino 制作的纸钢琴\ 梨木·乔
教程2:
youtube里面一个视频:
Arduino- 電容感應音樂樹
里面分享的教程

然后喇叭是怎么链接的。。。为什么我跟教程把+连去pin10 然后把-连接去GND 就完全没有声音,然后把+换去连接pin1时就有固定的响声。但是我触摸自己做的琴键时都没有反应。。。

有没有做过这个项目的人来帮忙我一下。完全不知道问题出哪里了。。。(电路连接错吗?怎么连接好((第一次摸这个东西。。。
代码编程我是直接拿link 1 里面的了。代码不知道有没有问题。。。。
回复

使用道具 举报

发表于 2019-9-6 10:22:46 | 显示全部楼层
沒看到你發出的 link。
youtube 的 link?
回复 支持 反对

使用道具 举报

发表于 2019-9-6 10:24:30 | 显示全部楼层
回复 支持 反对

使用道具 举报

发表于 2019-9-6 10:28:19 | 显示全部楼层
你所說的 教程1,是這個嗎?
http://limuqiao.com/2017/10/25/Arduino-en-paper-piano/
回复 支持 反对

使用道具 举报

发表于 2019-9-6 11:18:48 | 显示全部楼层
本帖最后由 eddiewwm 于 2019-9-6 11:21 编辑



喇叭接在 Pin_11 和 GND

程序:
  1. // Import the CapacitiveSensor Library.
  2. #include <CapacitiveSensor.h>



  3. #define speaker 11


  4. // Set the Send Pin & Receive Pin.
  5. CapacitiveSensor   cs_2_3 = CapacitiveSensor(2,3);        
  6. CapacitiveSensor   cs_2_4 = CapacitiveSensor(2,4);         
  7. CapacitiveSensor   cs_2_5 = CapacitiveSensor(2,5);     
  8. CapacitiveSensor   cs_2_6 = CapacitiveSensor(2,6);     
  9. CapacitiveSensor   cs_2_7 = CapacitiveSensor(2,7);      
  10. CapacitiveSensor   cs_2_8 = CapacitiveSensor(2,8);         
  11. CapacitiveSensor   cs_2_9 = CapacitiveSensor(2,9);  
  12. CapacitiveSensor   cs_2_10 = CapacitiveSensor(2,10);     


  13. void setup()                    
  14. {
  15.   cs_2_6.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
  16.   
  17.   // Arduino start communicate with computer.
  18.   Serial.begin(9600);
  19. }

  20. void loop()                    
  21. {
  22.   // Set a timer.
  23.   long start = millis();
  24.   
  25.   // Set the sensitivity of the sensors.
  26.   long total1 =  cs_2_3.capacitiveSensor(3000);
  27.   long total2 =  cs_2_4.capacitiveSensor(3000);
  28.   long total3 =  cs_2_5.capacitiveSensor(3000);
  29.   long total4 =  cs_2_6.capacitiveSensor(3000);
  30.   long total5 =  cs_2_7.capacitiveSensor(3000);
  31.   long total6 =  cs_2_8.capacitiveSensor(3000);
  32.   long total7 =  cs_2_9.capacitiveSensor(3000);
  33.   long total8 =  cs_2_10.capacitiveSensor(3000);
  34.   


  35.   Serial.print(millis() - start);        // check on performance in milliseconds
  36.   Serial.print("\t");                    // tab character for debug windown spacing

  37.   Serial.print(total1);                  // print sensor output 1
  38.   Serial.print("\t");                    // Leave some space before print the next output
  39.   Serial.print(total2);                  // print sensor output 2
  40.   Serial.print("\t");                    // Leave some space before print the next output
  41.   Serial.print(total3);                  // print sensor output 3
  42.   Serial.print("\t");                    // Leave some space before print the next output
  43.   Serial.print(total4);                  // print sensor output 4
  44.   Serial.print("\t");                    // Leave some space before print the next output
  45.   Serial.print(total5);                  // print sensor output 5
  46.   Serial.print("\t");                    // Leave some space before print the next output
  47.   Serial.print(total6);                  // print sensor output 6
  48.   Serial.print("\t");                    // Leave some space before print the next output
  49.   Serial.print(total7);                   // print sensor output 7
  50.                                           // Leave some space before print the next output
  51.   Serial.print("\t");
  52.   Serial.println(total8);                 // print sensor output 8
  53.                                          // "println" - "ln" represent as "line", system will jump to next line after print the output.
  54.   
  55.   
  56.   
  57.   
  58.   // When hand is touched the sensor, the speaker will produce a tone.
  59.   // I set a threshold for it, so that the sensor won't be too sensitive.
  60.   if (total1 > 500) tone(speaker,131);   // frequency
  61.   if (total2 > 500) tone(speaker,147);   // you can see https://www.arduino.cc/en/Tutorial/toneMelody if you want to change frequency
  62.   if (total3 > 500) tone(speaker,165);
  63.   if (total4 > 500) tone(speaker,175);
  64.   if (total5 > 500) tone(speaker,196);
  65.   if (total6 > 500) tone(speaker,220);
  66.   if (total7 > 500) tone(speaker,247);
  67.   if (total8 > 500) tone(speaker,262);
  68.   
  69.   // When hand didn't touch on it, no tone is produced.
  70.   if (total1<=500  &  total2<=500  &  total3<=500 & total4<=500  &  total5<=500  &  total6<=500 &  total7<=500 &  total8<=500)
  71.     noTone(speaker);

  72.   delay(10);                             // arbitrary delay to limit data to serial port
  73. }
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-6 16:49:43 来自手机 | 显示全部楼层
eddiewwm 发表于 2019-9-6 10:22
沒看到你發出的 link。
youtube 的 link?

是的。是那2个,但是我怎么做都不成功。
喇叭我换成0.5w的了。link我分享不到。。因为我按发布的时候他说我没有权限发布link...
回复 支持 反对

使用道具 举报

发表于 2019-9-6 16:55:04 | 显示全部楼层
DREAMY123 发表于 2019-9-6 16:49
是的。是那2个,但是我怎么做都不成功。
喇叭我换成0.5w的了。link我分享不到。。因为我按发布的时候他说 ...

注意 喇叭 接往 Pin_11 和 GND
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-6 17:57:07 来自手机 | 显示全部楼层
刚刚尝试了。一样不能。是不是电阻的关系?(电阻我用1m,会再去买2. 2m)还是我板子有问题。。。想去买个try看看。
回复 支持 反对

使用道具 举报

发表于 2019-9-6 18:05:01 | 显示全部楼层
DREAMY123 发表于 2019-9-6 17:57
刚刚尝试了。一样不能。是不是电阻的关系?(电阻我用1m,会再去买2. 2m)还是我板子有问题。。。想去买个tr ...

你先試一路,把兩個1M 串地起來用就可以得到 2M,不要急著買零件
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-6 20:03:09 来自手机 | 显示全部楼层
我尝试做了一个键。依旧没有反应。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2019-9-9 12:00:33 | 显示全部楼层
DREAMY123 发表于 2019-9-6 20:03
我尝试做了一个键。依旧没有反应。

接線位置改一下看看

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2019-9-9 16:37:43 | 显示全部楼层
有点像 makeymakey
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-9 20:53:57 来自手机 | 显示全部楼层
eddiewwm 发表于 2019-9-9 12:00
接線位置改一下看看

我做到了,但是不灵敏。代码改了灵敏度。。。但是怎么调都达不到碰了他就马上有反应要摸上大概30多秒吧。
调太灵敏他有时无缘无故的响。然后代码那边我没有用上面的了。找新的然后改了一点(不然speaker 响不停。。。要加no tone
再来就是声音不稳定。。。他不会跟着编码的声音走常常是一个音罢了。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-3-29 03:20 , Processed in 0.049981 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表