![](/media/cache/profiles/3cef5274bcca8c30f79c09a2aebc8669.jpg.50x50_q85.jpg)
A simple touch sensor that sends a message to computer when it notices touch. I'm using a simple voltage divider with 10k resistor and body impedance.
main.cpp
- Committer:
- tanssisatu
- Date:
- 2014-02-06
- Revision:
- 4:9afa1927a7bb
- Parent:
- 3:71bc9b90ff65
File content as of revision 4:9afa1927a7bb:
//Almighty Vekotin v.1.0 #include "mbed.h" #include "USBMIDI.h" #define A_key (0x1c) DigitalOut led(LED1); DigitalIn key[9] = {p22, p23, p24, p25, p26, p27, p28, p29, p30}; //inputit int input = 0; int painetut_nappaimet[9] = {0}; Serial pc(USBTX, USBRX); //Debuggaus päällä //USBMIDI midi; // Midi päällä int main() { while (1) { // Tallentaa pitchin // Tallentaa painallukset for (i = 0; i < 9; i++) { if (input = key[i].read()) painetut_nappaimet[i] = 1; } // Lähettään painallusten perusteella midimessagen for (i = 0; i < 9; i++) { if (painetut_nappaimet[i]) //midi.write(MIDIMessage::Noteon(48 + i)); // Debuggaus puttyyn pc.printf("Digital input %d", i); //terminal viesti pc.printf(": %d\n\r", key[i].read()); } // Lopettaa midimessagen lähettämisen for (i = 0; i < 9; i++) { if (painetut_nappaimet[i]) wait(1);//midi.write(MIDIMessage::NoteOff(48 + i)); } } }