如题,
自己每次摸到乐器就会yy弹琴的样子: 如下
实在不济也是

家里妹子不久前告诉我“其实你是酱紫”
当时老子的心里是崩溃的

之前蘑菇云扔了台激光竖琴,卤煮家妹子做的,但带出去文(zhuang)艺(bi)实在是不方便。
所以就心想能不能搞个小的,出去浪也方便啊。

说搞就搞,身为蘑菇云搞事情一把手 首先是 买买买BOM清单
1> Φ12mm直径10mW532nm绿光激光模组点状定位瞄准绿色激光头发射管 * 7
2> 模拟环境光线传感器(Arduino兼容) DFR0026 * 7
3> DFRduino Mega2560 V3.0控制器 DFR0165* 1
别问我为啥用mega,有钱任性(要7个模拟口啊妈蛋,uno只有6个啊mdzz)
4> DFR0165 MEGA传感器扩展板 V2.4 (Arduino兼容) * 1
5> MIDIPLUS miniengine USB MIDI键盘专用硬音源 合成器音源 *1
(这个音源也能当充电宝给arduino供电,好方便哈哈哈哈哈哈)
6> 合成板木片,激光切割板材600mm*600mm*4mm * 6 留了一张备用
7> 3v2a电源适配器 * 1
也别问我为啥用这么奇葩的电源适配器,激光头是3V的,实测电流300mA,7个加起来共2.1A,能买到的功率最大的就3v2a,凑合用了(应该炸不了)。。。
8> midi连接线,USB连接线,等等。

制作过程 之 切割木板,装配(图纸已上传):
    
从下到上,共5层,分别为底板,夹层板*3(包括激光头位置,线位,洞洞板的位置),面板(雕刻花纹,logo)
一层一层的叠起来 ↓↓↓

中间是激光头的卡槽 ↓↓↓

激光头装进去,线路焊在洞洞板上,接出正负极两根线,盖上面板,上螺丝。
 
然后安装传感器在上面,用万能的热胶枪

完了再把mega主控板pia唧到上面,接线。

成品图是酱紫的


当然身体有了,还缺个聪明的大脑,下面程序奉上
- /***************************************************************************
- * 激光竖琴 *
- * Version: 1.0.0 *
- * Date: Apr 06 2017 *
- * Name: Richard Lyu *
- * Email: <a href="mailto:Richard.lyu@dfrobot.com" target="_blank">Richard.lyu@dfrobot.com</a> *
- * *
- ***************************************************************************/
-
- static const unsigned ledPin = 13; // LED pin on Arduino Uno
- static const unsigned Laser[] = {A6,A7,A8,A9,A10,A11,A12}; // Laser on Arduino Uno
- static const unsigned LaserThreshold = 500; // 阈值,调整大小以适应外部环境光线条件
- static const unsigned note[] = {42,43,44,45,46,47,48}; // 修改数组里的数字 调整音高
-
- void setup()
- {
- pinMode(ledPin, OUTPUT);
- Serial.begin(31250);
-
-
- // play notes from F#-0 (0x1E) to F#-5 (0x5A):
- for (int i = 0x1E; i < 0x5A; i++) {
- //Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
- noteOn(0x90, i, 0x45); // Send a Note (pitch 42, velo 127 on channel 1)
- delay(100);
- //Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
- noteOn(0x90, i, 0x00); // Send a Note (pitch 42, velo 127 on channel 1)
- delay(100);
- }
- }
-
- bool StatePre[7] = {false,false,false,false,false,false,false};
- bool StateCur[7] = {false,false,false,false,false,false,false};
-
- // plays a MIDI note. Doesn't check to see that
- // cmd is greater than 127, or that data values are less than 127:
- void noteOn(int cmd, int pitch, int velocity) {
- Serial.write(cmd);
- Serial.write(pitch);
- Serial.write(velocity);
- }
-
- void loop()
- {
- for(int i = 0;i<7;i++){
- /******* Detecting currently if the laser is fired on the sensor **********/
- if (analogRead(Laser) > LaserThreshold ){
- StateCur = true;
- }else{
- StateCur = false;
- }
-
- /******** Determine if sound should be played *************/
-
- if(StateCur == true && StatePre == false){
- noteOn(0x90, note, 0x45);
- digitalWrite(ledPin, HIGH);
- }else if(StateCur == true && StatePre == false){
- noteOn(0x90, note, 0x00);
- digitalWrite(ledPin, LOW);
- }
-
- /****** shifting in the current state to previous state ***************/
- StatePre = StateCur;
- }
- delay(50);
- }
复制代码
最后放上演奏效果
嗨我就不明白,为啥汉子和妹子差距这么多呢(看下面视频)
@nicho
|