PianoDuino (Arduino + Processing + SoundCipher)
PianoDuino é um experimento simples que integra Arduino, Processing e uma biblioteca para manipular sons, a SoundCipher. A idéia serviu para experimentar o Multiplexador / Demultiplexador 4051.
PianoDuino (Arduino + Processing + SoundCipher) from Bruno Soares on Vimeo.
Arduino:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /** * PianoDuino * * @author Bruno Soares * @link http://www.bsoares.com.br * @language Arduino / C++ */ #define PIN_SELECTOR0 2 #define PIN_SELECTOR1 3 #define PIN_SELECTOR2 4 int value; int count; // Selectors byte s0; byte s1; byte s2; void setup() { Serial.begin(9600); pinMode(PIN_SELECTOR0, OUTPUT); pinMode(PIN_SELECTOR1, OUTPUT); pinMode(PIN_SELECTOR2, OUTPUT); } void loop() { for (count = 0; count < 8; count++) { // Extract active bits s0 = count & 0x1; s1 = (count >> 1) & 0x1; s2 = (count >> 2) & 0x1; // Select input digitalWrite(2, s0); digitalWrite(3, s1); digitalWrite(4, s2); // Read input selected value = analogRead(0); if (value > 5) { Serial.print(count); while(analogRead(0) > 5); } } } |
Processing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /** * PianoDuino * * @author Bruno Soares * @link http://www.bsoares.com.br * @language Processing */ import arb.soundcipher.*; import processing.serial.*; SoundCipher[] sc = new SoundCipher[8]; Serial port; int portValue = 0; void setup() { for (int i = 0; i < sc.length; i++) { sc[i] = new SoundCipher(this); } println(Serial.list()); port = new Serial(this, Serial.list()[1], 14400); } void draw() { while (port.available() > 0) { portValue = int(port.readString().substring(0, 1)); print(portValue); sc[portValue].playNote(80 - (portValue * 7), 100, 2.5); } } |
Baixe o código fonte completo aqui.
Conteúdo relacionado:
Fotos no Flickr
Arduino
Processing
SoundCipher
Analog multiplexer / demultiplexer 4051
Posts relacionados:

Será que tem como disponibilizar o esquema de ligações?
valeu pelo projecto,,, esta muito bom mesmo.
Pô vai dar um trampinho fazer este esquema, mas faz assim, se você entender como funciona o Mux/Demux 4051 (http://www.arduino.cc/playground/Learning/4051) você mata a solução do esquema.
Boa sote, é facinho ;)
gostei muito dos projetos principalmento com arduino pretendo testar.