zmg 发表于 2020-5-6 19:33:36

和弦吉他的设计与制作

本帖最后由 zmg 于 2020-5-6 19:33 编辑

https://mc.dfrobot.com.cn/data/attachment/forum/201911/27/152702ejn5evjznj93b9pj.gif

【视频演示】
https://v.qq.com/txp/iframe/player.html?vid=n3026rf13vn


       由于CocoTouch编程板它内置MIDI控制器,集成了120多种乐器,加上编好程序后可以脱离电脑运行,直接插上音箱就行了,所以非常适合制作乐器。在上两期中分别介绍了炫彩电子钢琴和架子鼓的设计与制作,这一次我们再来设计制作一把和弦吉他。

【工作原理】       这个吉他的工作原理:吉他琴颈上的6个强磁通过导线与控制板上的0—5号触点相连,琴码上的6个铜盖型螺母通过导线与控制板上的6—11号触点相连,再通过编写相应的程序,就能实现了把琴颈上的 6 个强磁触控点变成了 6 个和弦按钮,琴码上的 6 个铜盖型螺母触控点变成了吉他的6 根琴弦,这样弹奏者在弹奏时只要按住其中一个和弦按钮,然后拨动琴弦,便可发出对应的和弦声音了,而且在弹奏的过程中音孔位置还会亮起非常炫酷的灯光效果,如果不弹奏灯就会熄灭。当然我们还可以通过修改程序来实现不同6个和弦的分布,也可以分解和弦等。       我们把相对应的程序编写好上传到控制板后,这时只要用冲电宝等给控制板供电,再把音箱直接插在侧面板的耳机连接线音频输出口上,弹奏吉他时,音箱就会发出相对应的音了。
【硬件清单】      CocoTouch 可编程控制板      WS2812 RGB LED灯环      接线端子      耳机延长线      铜螺丝、螺帽、铜盖型螺母及垫片      圆形稀土钕铁硼强磁      连接导线      铆钉      激光切割件

【制作过程】       1、结构图设计并切割       我们先利用软件在电脑中设计出吉他的结构件,材料用椴木板和白色的亚克力板,并用激光切割机进行切割。图纸上黑色的线表示要切透,红色的表示不切透只划线,蓝色框内的材料是白色的亚克力板。
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181014ijqmp1fwg9t8qs3b.jpg
       2、琴颈面板的制作       我们把6个10MM的圆形稀土钕铁硼强磁安装在琴颈面板的六个孔上,然后把剥了线的6根导线的一端用铜箔胶带贴在圆形强磁,这样能保证良好的导电性,最后再用热熔胶进行固定。这里的六个圆形强磁通过导线与主控板对应的接口相连接,再通过程序的编写从而实现按不同的圆形强磁可以弹出不同的和弦音的效果,也就是由这6个触控点来完成 6 个和弦按钮的功能。
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181014nuenb28ahza26ihm.jpg
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181014s8nnc2881i5mp5rv.jpg
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181015m9aczyyhbhsmbz9s.jpg
       3、琴码的制作       把相对应的椴木条和亚克力条用502胶水粘在一起,再把6个铜盖型螺母固定在相应的6个孔内。这个结构的功能并不是作为琴码使用,它的实际功能相当于琴弦,等下我们再把这6个铜盖型螺母通过铜螺丝、铜垫片和导线,使之与主控板相对应的接口相连,再通过编写程序从而实现触碰不同的铜盖型螺母就相当于拨动不同的琴弦的效果。
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181015ij3nnq332x55whg3.jpg
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181016vx27cq2zzzbcxzii.jpg
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181016gjlum8fmzlfffvum.jpg
       4、把琴码固定在吉他的面板上,并在音孔上贴上圆形的亚克力板。      我们利用铜螺丝、铜垫片把琴码固定在吉他面板上,在固定时把导线也连接上,这里用铜螺丝、铜垫片主要也是为了实现良好的导电性。接着把圆形的亚克力板用热熔胶固定在吉他面板的音孔上,这里用亚克力板的目的一是美化作用,二是柔化下面灯环发出的光线。
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181017lmb0n0iwwh4din4h.jpg
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181344pb9oqj9vf1cwjq3w.jpg
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181345j0lbpiogtokxpvo5.jpg
       5、组装吉他。       如下图所示,我们把吉它的外框架子组装好并用热熔胶固定,接着把耳机延长线也安装在相对应的侧面板上,并用热熔胶进行固定,最后再把面板安装上。
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181345moxdkh4px0655d6n.jpg
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181346xxu4znmknku2o62n.jpg
       6、安装灯环。      先把3根导线焊接在灯环上,红色导线焊接在灯环的VCC上,黑色导线焊接在GND上,黄色导线焊接在DI上,接着把灯环用热熔胶固定在木板上,再把它们固定在面板的背面音孔处,固定时注意要使灯环处在音孔的中间,这样效果比较好。
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181347t364lqpa8a70l5ie.jpg
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181347a7qi5zz8n8087jzi.jpg
       7、安装CocoTouch可编程控制板。       我们先把12根导线的一头用铜的螺丝、螺母和垫片固定在CocoTouch 可编程控制板的0—11的触控孔上,这里用铜的螺丝、螺母和垫片也是为了实现良好的导电性,接着再把控制板固定在底板上,再在底板的一侧安装上接线端子,方便导线的连接。
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181348s7dwkanmaf5l4sk2.jpg
       8、线路连接。       把琴颈面板上与6个强磁连接的线通过接线端子与CocoTouch 可编程控制板上的0—5的触控点引出的导线依次相连,而琴码上引出的6根导线也通过接线端子与控制板上的6—11的触控点引出的导线依次相连,再把灯带的VCC、GND接线插在主控板上的VCC、GND针脚上,把灯带上的控制信号输入端也就是DI这根线插在主控板的D2针脚上(这里主控板事先这几个针脚并没有焊上,所以我们事先要先焊上这几根针脚),最后把耳机连接线一头插在控制板的音频输出口上。
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181349c7f8j1f8nlj97914.jpg

       9、安装上底板及面板装饰条。       最后我们把底板和面板装饰条安装上,这里的底板与吉他架子利用铆钉进行固定,方面以后的检修,这样一把吉他就组装完成了。
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181349lzi94lflh0q7f0rs.jpg
https://mc.dfrobot.com.cn/data/attachment/forum/201911/11/181350nfj8n8ff8vny2sv8.jpg

【程序编写】       程序是利用Arduino IDE编写的,详细程序如下:
纯文本查看 复制代码
?

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#include "cocotouch.h"
#include <Adafruit_NeoPixel.h>
#define PIN 2   //The signal pin connected with Arduino
#define LED_COUNT 16 // the amount of the leds of your strip
char itemIndex;
uint8_t idx;
uint8_t midiNotes;
uint8_t states;
CocoTouch touch;
Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
if (!touch.begin()) { while(1){;} }
touch.setMIDIProgram(26, 1);
leds.begin();// Call this to start up the LED strip.
clearLEDs();   // This function, defined below, turns all LEDs off...
leds.show();   // ...but the LEDs don't actually update until you call this.
}

void loop() {
for (idx = 6; idx <= 11; idx++) {
itemIndex = idx - 6;
if (states == 0 && touch.getTouched(idx) == 1) {
touch.playMIDINote(midiNotes, 100, 1);
states = 1;
} else if (states == 1 && touch.getTouched(idx) < 1) {
states = 0;
}
}
if (touch.getTouched(0) == 1) {
midiNotes = 43;
midiNotes = 48;
midiNotes = 52;
midiNotes = 55;
midiNotes = 60;
midiNotes = 64;

for (int i=0; i<LED_COUNT; i++)
{
rainbow(i);
delay(10);// Delay between rainbow slides
}
      
} else if (touch.getTouched(1) == 1) {
midiNotes = 45;
midiNotes = 50;
midiNotes = 54;
midiNotes = 57;
midiNotes = 62;
midiNotes = 66;
for (int i=0; i<LED_COUNT; i++)
{
rainbow(i);
delay(10);// Delay between rainbow slides
}
      
} else if (touch.getTouched(2) == 1) {
midiNotes = 43;
midiNotes = 47;
midiNotes = 52;
midiNotes = 55;
midiNotes = 59;
midiNotes = 64;
for (int i=0; i<LED_COUNT; i++)
{
rainbow(i);
delay(10);// Delay between rainbow slides
}
      
} else if (touch.getTouched(3) == 1) {
midiNotes = 45;
midiNotes = 48;
midiNotes = 53;
midiNotes = 57;
midiNotes = 60;
midiNotes = 65;
for (int i=0; i<LED_COUNT; i++)
{
rainbow(i);
delay(10);// Delay between rainbow slides
}
      
} else if (touch.getTouched(4) == 1) {
midiNotes = 47;
midiNotes = 50;
midiNotes = 55;
midiNotes = 59;
midiNotes = 62;
midiNotes = 67;
for (int i=0; i<LED_COUNT; i++)
{
rainbow(i);
delay(10);// Delay between rainbow slides
}
} else if (touch.getTouched(5) == 1) {
midiNotes = 45;
midiNotes = 48;
midiNotes = 52;
midiNotes = 57;
midiNotes = 60;
midiNotes = 64;
for (int i=0; i<LED_COUNT; i++)
{
rainbow(i);
delay(10);// Delay between rainbow slides
}
} else {
leds.begin();// Call this to start up the LED strip.
clearLEDs();   // This function, defined below, turns all LEDs off...
leds.show();   // ...but the LEDs don't actually update until you call this.

}
}

void clearLEDs()
{
for (int i=0; i<LED_COUNT; i++)
{
leds.setPixelColor(i, 0);
}
}

// Prints a rainbow on the ENTIRE LED strip.
//The rainbow begins at a specified position.
// ROY G BIV!
void rainbow(byte startPosition)
{
// Need to scale our rainbow. We want a variety of colors, even if there
// are just 10 or so pixels.
int rainbowScale = 192 / LED_COUNT;
   
// Next we setup each pixel with the right color
for (int i=0; i<LED_COUNT; i++)
{
// There are 192 total colors we can get out of the rainbowOrder function.
// It'll return a color between red->orange->green->...->violet for 0-191.
leds.setPixelColor(i, rainbowOrder((rainbowScale * (i + startPosition)) % 192));
}
// Finally, actually turn the LEDs on:
leds.show();
}

// Input a value 0 to 191 to get a color value.
// The colors are a transition red->yellow->green->aqua->blue->fuchsia->red...
//Adapted from Wheel function in the Adafruit_NeoPixel library example sketch
uint32_t rainbowOrder(byte position)
{
// 6 total zones of color change:
if (position < 31)// Red -> Yellow (Red = FF, blue = 0, green goes 00-FF)
{
return leds.Color(0xFF, position * 8, 0);
}
else if (position < 63)// Yellow -> Green (Green = FF, blue = 0, red goes FF->00)
{
position -= 31;
return leds.Color(0xFF - position * 8, 0xFF, 0);
}
else if (position < 95)// Green->Aqua (Green = FF, red = 0, blue goes 00->FF)
{
position -= 63;
return leds.Color(0, 0xFF, position * 8);
}
else if (position < 127)// Aqua->Blue (Blue = FF, red = 0, green goes FF->00)
{
position -= 95;
return leds.Color(0, 0xFF - position * 8, 0xFF);
}
else if (position < 159)// Blue->Fuchsia (Blue = FF, green = 0, red goes 00->FF)
{
position -= 127;
return leds.Color(position * 8, 0, 0xFF);
}
else//160 <position< 191   Fuchsia->Red (Red = FF, green = 0, blue goes FF->00)
{
position -= 159;
return leds.Color(0xFF, 0x00, 0xFF - position * 8);
}
}








页: [1]
查看完整版本: 和弦吉他的设计与制作