触控钢琴
2016-07-311.9万
AI 快速预览详细
触控钢琴是一个基于Arduino Uno和TTP229触摸键盘的音乐项目。通过简单的电路连接和代码编写,用户可以创建一个能够通过触摸按键触发音符的电子乐器。该项目适合零基础新手和STEM教育场景,能够激发孩子的创造力。硬件清单包括Arduino Uno、MP3模块和8欧喇叭。最终效果是一个可以演奏音乐的触控钢琴,难度适中。
|
触控钢琴 调试设备:Arduino uno MP3 module 8欧喇 叭![]() ![]() ![]() ![]() touchPiano.rarTTP229 16 Key Capacitive Keypad 是个IIC模块,1.....VCC (2.4 - 5.5V) 2.....GND 3.....SCL (serial clock in) 4.....SDO (serial data out) 5.....OUT 1 (key 1 state) 6.....OUT 2 (key 2 state) 7.....OUT 3 (key 3 state) 8.....OUT 4 (key 4 state) 9.....OUT 5 (key 5 state) 10...OUT 6 (key 6 state) 11...OUT 7 (key 7 state) 12...OUT 8 (key 8 state) ![]() ![]() ![]() ![]() [mw_shl_code=applescript,true]/*FILE: TTP229_16_Key_Capacitive_Touch_Example DATE: 25/02/15 VERSION:0.1 REVISIONS: 25/02/15 Createdversion 0.1 Thisis an exampleof howtouse the Hobby Components16 key capacitive touch keypad(HCMODU0079). Thisexamplesketch will read the currentstate of the ofthekeypadand if a key ispressed outputitskey number tothe serial port. The sketch assumesthatthe keypadis configuredto 16 keyactive low mode byshortingpadsP1-3 andP1-P4 together (see schematic orsport forum for more information).Connect thekeypad to your Arduinoas follows: Keypad......Arduino VCC.........+5V GND.........GND SCL.........Digital pin8 SDO.........Digital pin9 You may copy,alter andreusethiscodein any way you like, but please leave referenceto HobbyComponents.com in your comments if you redistribute this code. Thissoftwaremay not be useddirectly for the purpose of promotingproducts that directly competewith Hobby Components Ltd'sownrange of products. THISSOFTWAREISPROVIDED"ASIS".HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER EXPRESS,IMPLIED OR STATUTORY, INCLUDING, BUTNOT LIMITED TO, IMPLIED WARRANTIES OFMERCHANTABILITYANDFITNESS FOR A PARTICULARPURPOSE,ACCURACY OR LACKOF NEGLIGENCE. HOBBYCOMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BELIABLE FOR ANY DAMAGES INCLUDING, BUT NOTLIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIALDAMAGES FORANYREASON WHATSOEVER.*/ /*Definethedigital pins used for theclock and data */ #define SCL_PIN 8 #define SDO_PIN 9 /*Used to storethe key state */ byteKey; voidsetup() { /*Initialise the serial interface */ Serial.begin(9600); /*Configure theclock anddatapins */ pinMode(SCL_PIN,OUTPUT); pinMode(SDO_PIN,INPUT); } /*Main program */ voidloop() { /*Readthecurrent state of thekeypad */ Key = Read_Keypad(); /*If akeyhas been pressed output it tothe serial port */ if(Key) Serial.println(Key); /*Waitalittlebeforereadingagain so notto flood the serial port*/ delay(100); } /*Read thestate of the keypad */ byteRead_Keypad(void) { byteCount; byteKey_State=0; /*Pulse the clock pin 16 times(one for each key of thekeypad) and readthe stateof the data pinon each pulse*/ for(Count=1;Count <=16;Count++) { digitalWrite(SCL_PIN,LOW); /*Ifthedatapin islow(active low mode) then storethe current keynumber*/ if(!digitalRead(SDO_PIN)) Key_State = Count; digitalWrite(SCL_PIN,HIGH); } return Key_State; }[/mw_shl_code] |
-
DSCN0149.JPG (100.82 KB, 下载次数: 4753)
-
125141m0qzi55z5i8rgj71.png (386.93 KB, 下载次数: 4729)
-
-
678.31 KB, 下载次数: 6173


叭










