2018年12月20日 星期四

weel15_鄭昕恬

我們想做的是有關打鼓的互動程式
其˙實網路上有許多範本可以參考
但是實際要做起來還是沒有那麼容易

我們先到網路上訂購"麵包板"
還有"公對母的連接線"
再配上老師上課所搭配的"MakerUNO "
其他部分還在構思中
主要參考的連結是:https://www.youtube.com/watch?v=qweE762Z03M

有問題還會持續詢問老師





#include <CapacitiveSensor.h>
#define threshold 30 // 感測電容量的臨界值 byte note; CapacitiveSensor cs_4_5 = CapacitiveSensor(4,5); CapacitiveSensor cs_4_6 = CapacitiveSensor(4,6); CapacitiveSensor cs_4_7 = CapacitiveSensor(4,7); CapacitiveSensor cs_4_8 = CapacitiveSensor(4,8); CapacitiveSensor cs_4_9 = CapacitiveSensor(4,9); void midiMsg(byte cmd, byte pitch, byte velocity){ Serial.write(cmd); Serial.write(pitch); Serial.write(velocity); } void setup() { // put your setup code here, to run once: Serial.begin(115200); Serial.write(0xC0); Serial.write(0x0A); } void loop() { // put your main code here, to run repeatedly: long total1 = cs_4_5.capacitiveSensor(30); long total2 = cs_4_6.capacitiveSensor(30); long total3 = cs_4_7.capacitiveSensor(30); long total4 = cs_4_8.capacitiveSensor(30); long total5 = cs_4_9.capacitiveSensor(30); if (total1 > threshold) { midiMsg(10011001, 46, 0x40); } if (total2 > threshold) { midiMsg(0x99, 35, 0x40); } if (total3 > threshold) { midiMsg(0x99, 41, 0x40); } if (total4 > threshold) { midiMsg(0x99, 43, 0x40); } if (total5 > threshold) { midiMsg(0x99, 45, 0x40); } delay(200);


沒有留言:

張貼留言