Lukas
12 years ago
8 changed files with 137 additions and 137 deletions
-
BINdesign_files/design.odg
-
BINfritzing_files/INPUT_PLATINE.fzz
-
20source/ConnectionChecker/ConnectionChecker.ino
-
47source/INPUT_MCP23017_test/INPUT_MCP23017_test.ino
-
99source/MCP23017_test/MCP23017_test.ino
-
102source/_2013_05_08/_2013_05_08.ino
-
4source/libraries/bombatuino_INPUT_74HC4051/bombatuino_INPUT_74HC4051.cpp
-
2source/libraries/bombatuino_INPUT_74HC4051/bombatuino_INPUT_74HC4051.h
@ -0,0 +1,20 @@ |
|||
const int buttonPin = 2; // the number of the pushbutton pin
|
|||
const int ledPin = 13; // the number of the LED pin
|
|||
|
|||
void setup() { |
|||
// initialize the LED pin as an output:
|
|||
pinMode(ledPin, OUTPUT); |
|||
// initialize the pushbutton pin as an input:
|
|||
pinMode(buttonPin, INPUT); |
|||
digitalWrite(buttonPin, HIGH); |
|||
} |
|||
|
|||
void loop(){ |
|||
int buttonState = digitalRead(buttonPin); |
|||
if (buttonState == LOW) { |
|||
digitalWrite(ledPin, HIGH); |
|||
} |
|||
else { |
|||
digitalWrite(ledPin, LOW); |
|||
} |
|||
} |
@ -1,99 +0,0 @@ |
|||
#include <Wire.h>
|
|||
|
|||
#define MCP23017_ADDRESS 0x20
|
|||
|
|||
// registers (from https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library/blob/master/Adafruit_MCP23017.h)
|
|||
#define MCP23017_IODIRA 0x00
|
|||
#define MCP23017_IPOLA 0x02
|
|||
#define MCP23017_GPINTENA 0x04
|
|||
#define MCP23017_DEFVALA 0x06
|
|||
#define MCP23017_INTCONA 0x08
|
|||
#define MCP23017_IOCONA 0x0A
|
|||
#define MCP23017_GPPUA 0x0C
|
|||
#define MCP23017_INTFA 0x0E
|
|||
#define MCP23017_INTCAPA 0x10
|
|||
#define MCP23017_GPIOA 0x12
|
|||
#define MCP23017_OLATA 0x14
|
|||
|
|||
#define MCP23017_IODIRB 0x01
|
|||
#define MCP23017_IPOLB 0x03
|
|||
#define MCP23017_GPINTENB 0x05
|
|||
#define MCP23017_DEFVALB 0x07
|
|||
#define MCP23017_INTCONB 0x09
|
|||
#define MCP23017_IOCONB 0x0B
|
|||
#define MCP23017_GPPUB 0x0D
|
|||
#define MCP23017_INTFB 0x0F
|
|||
#define MCP23017_INTCAPB 0x11
|
|||
#define MCP23017_GPIOB 0x13
|
|||
#define MCP23017_OLATB 0x15
|
|||
|
|||
int _addr = 0; |
|||
int _value[16]; |
|||
|
|||
void setup() { |
|||
Serial.begin(9600); |
|||
Wire.begin(); |
|||
|
|||
// set defaults!
|
|||
Wire.beginTransmission(MCP23017_ADDRESS | _addr); |
|||
Wire.write((byte)MCP23017_IODIRA); |
|||
Wire.write(0xFF); // all inputs on port A
|
|||
Wire.endTransmission(); |
|||
|
|||
Wire.beginTransmission(MCP23017_ADDRESS | _addr); |
|||
Wire.write(MCP23017_IODIRB); |
|||
Wire.write(0xFF); // all inputs on port B
|
|||
Wire.endTransmission(); |
|||
|
|||
|
|||
Wire.beginTransmission(MCP23017_ADDRESS | _addr); |
|||
Wire.write(MCP23017_GPPUA); |
|||
Wire.write(0xFF); // all pullup resistors on port A
|
|||
Wire.endTransmission(); |
|||
|
|||
Wire.beginTransmission(MCP23017_ADDRESS | _addr); |
|||
Wire.write(MCP23017_GPPUB); |
|||
Wire.write(0xFF); // all pullup resistors on port B
|
|||
Wire.endTransmission(); |
|||
} |
|||
|
|||
void loop() { |
|||
uint8_t pin,bank; |
|||
int value; |
|||
//read bank A
|
|||
Wire.beginTransmission(MCP23017_ADDRESS | _addr); |
|||
Wire.write(MCP23017_GPIOA); |
|||
Wire.endTransmission(); |
|||
Wire.requestFrom(MCP23017_ADDRESS | _addr, 1); |
|||
bank = Wire.read(); |
|||
for (pin=0; pin<8; pin++) { |
|||
value = (bank >> pin) & 0x1; |
|||
if (_value[pin] != value) { |
|||
_value[pin] = value; |
|||
printValue(_addr,pin,value); |
|||
} |
|||
} |
|||
//read bank B
|
|||
Wire.beginTransmission(MCP23017_ADDRESS | _addr); |
|||
Wire.write(MCP23017_GPIOB); |
|||
Wire.endTransmission(); |
|||
Wire.requestFrom(MCP23017_ADDRESS | _addr, 1); |
|||
bank = Wire.read(); |
|||
for (pin=8; pin<16; pin++) { |
|||
value = (bank >> (pin-8)) & 0x1; |
|||
if (_value[pin] != value) { |
|||
_value[pin] = value; |
|||
printValue(_addr,pin,value); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void printValue(int id, int pin, int value) { |
|||
Serial.print("id: "); |
|||
Serial.print(id); |
|||
Serial.print(" pin: "); |
|||
Serial.print(pin); |
|||
Serial.print(" value: "); |
|||
Serial.print(value); |
|||
Serial.println(); |
|||
} |
@ -0,0 +1,102 @@ |
|||
#include <Wire.h>
|
|||
|
|||
#include <bombatuino_INPUT_MCP23017.h>
|
|||
#include <bombatuino_INPUT_74HC4051.h>
|
|||
#include <bombatuino_ROTARY_ENCODER.h>
|
|||
#include <bombatuino_MIDI.h>
|
|||
|
|||
|
|||
MIDI Midi; |
|||
|
|||
INPUT_MCP23017 input_MCP23017_0; |
|||
INPUT_MCP23017 input_MCP23017_1; |
|||
INPUT_MCP23017 input_MCP23017_3; |
|||
INPUT_MCP23017 input_MCP23017_4; |
|||
|
|||
ROTARY_ENCODER re_JogWheel1(rotaryLeftJogWheel1,rotaryRightJogWheel1); |
|||
ROTARY_ENCODER re_JogWheel2(rotaryLeftJogWheel2,rotaryRightJogWheel2); |
|||
ROTARY_ENCODER re_Browse(rotaryLeftBrowse,rotaryRightBrowse); |
|||
INPUT_74HC4051 input_4051_A0; |
|||
INPUT_74HC4051 input_4051_A1; |
|||
INPUT_74HC4051 input_4051_A2; |
|||
|
|||
void setup() { |
|||
Midi.begin(); |
|||
input_MCP23017_0.begin(0,printDigitalData); |
|||
input_MCP23017_1.begin(1,printDigitalData); |
|||
input_MCP23017_3.begin(3,printDigitalData); |
|||
input_MCP23017_4.begin(4,printDigitalData); |
|||
|
|||
input_4051_A0.begin(A0,8,9,10,printAnalogData); |
|||
input_4051_A1.begin(A1,8,9,10,printAnalogData); |
|||
input_4051_A2.begin(A2,8,9,10,printAnalogData); |
|||
} |
|||
|
|||
void loop() { |
|||
input_MCP23017_0.loop(); |
|||
input_MCP23017_1.loop(); |
|||
input_MCP23017_3.loop(); |
|||
input_MCP23017_4.loop(); |
|||
input_4051_A0.loop(); |
|||
input_4051_A1.loop(); |
|||
input_4051_A2.loop(); |
|||
} |
|||
|
|||
void printAnalogData(int id, int pin, int value) { |
|||
Midi.controlChange((id-A0) * 8 + pin,value); |
|||
} |
|||
|
|||
void printDigitalData(int id, int pin, int value) { |
|||
if (id == 1 && pin == 6) |
|||
re_JogWheel1.setPinA(value); |
|||
if (id == 1 && pin == 7) |
|||
re_JogWheel1.setPinB(value); |
|||
if (id == 3 && pin == 9) |
|||
re_JogWheel2.setPinA(value); |
|||
if (id == 3 && pin == 10) |
|||
re_JogWheel2.setPinB(value); |
|||
if (id == 3 && pin == 6) |
|||
re_Browse.setPinA(value); |
|||
if (id == 3 && pin == 5) |
|||
re_Browse.setPinB(value); |
|||
if ((id == 3 && pin != 5 && pin != 6 && pin!= 9 && pin != 10) || (id == 1 && pin != 6 && pin !=7) || (id == 0) || (id == 4)) { |
|||
if (value == HIGH) |
|||
Midi.noteOn(id * 16 + pin, MIDI_MAX_DATA); |
|||
else Midi.noteOff(id * 16 + pin); |
|||
} |
|||
} |
|||
|
|||
//JogWheel1
|
|||
void rotaryLeftJogWheel1() { |
|||
Midi.noteOn(1 * 16 + 6, MIDI_MAX_DATA); |
|||
Midi.noteOff(1 * 16 + 6); |
|||
} |
|||
|
|||
void rotaryRightJogWheel1() { |
|||
Midi.noteOn(1 * 16 + 7, MIDI_MAX_DATA); |
|||
Midi.noteOff(1 * 16 + 7); |
|||
} |
|||
|
|||
|
|||
//JogWheel2
|
|||
void rotaryLeftJogWheel2() { |
|||
Midi.noteOn(3 * 16 + 9, MIDI_MAX_DATA); |
|||
Midi.noteOff(3 * 16 + 9); |
|||
} |
|||
|
|||
void rotaryRightJogWheel2() { |
|||
Midi.noteOn(3 * 16 + 10, MIDI_MAX_DATA); |
|||
Midi.noteOff(3 * 16 + 10); |
|||
} |
|||
|
|||
|
|||
//Browse
|
|||
void rotaryLeftBrowse() { |
|||
Midi.noteOn(3 * 16 + 6, MIDI_MAX_DATA); |
|||
Midi.noteOff(3 * 16 + 6); |
|||
} |
|||
|
|||
void rotaryRightBrowse() { |
|||
Midi.noteOn(3 * 16 + 5, MIDI_MAX_DATA); |
|||
Midi.noteOff(3 * 16 + 5); |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue