update
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include <Wire.h>
|
||||
|
||||
#include <bombatuino_INPUT_MCP23017.h>
|
||||
#include <bombatuino_INPUT_74HC4051.h>
|
||||
#include <bombatuino_ROTARY_ENCODER.h>
|
||||
|
||||
INPUT_MCP23017 input_MCP23017;
|
||||
INPUT_74HC4051 input_4051;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
input_MCP23017.begin(0,printData);
|
||||
input_4051.begin(A3,10,11,12,printData);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
input_MCP23017.loop();
|
||||
input_4051.loop();
|
||||
}
|
||||
|
||||
void printData(int id, int pin, int value) {
|
||||
Serial.print("id");
|
||||
Serial.print(id);
|
||||
Serial.print(" - ");
|
||||
Serial.print("pin");
|
||||
Serial.print(pin);
|
||||
Serial.print(" : ");
|
||||
Serial.print(value);
|
||||
Serial.println();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
#include <bombatuino_MIDI.h>
|
||||
|
||||
MIDI Midi;
|
||||
|
||||
void setup() {
|
||||
Midi.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Midi.noteOn(0x3C,0x64);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
int tolerance = 4;
|
||||
|
||||
const int s0 = 10;
|
||||
const int s1 = 9;
|
||||
const int s2 = 8;
|
||||
|
||||
int pots[] = {-1,-1};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
pinMode(s0,OUTPUT);
|
||||
pinMode(s1,OUTPUT);
|
||||
pinMode(s2,OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//get Y0 of 4051
|
||||
digitalWrite(s0, LOW);
|
||||
digitalWrite(s1, LOW);
|
||||
digitalWrite(s1, LOW);
|
||||
int read = analogRead(A1);
|
||||
//only print value on change (tolerance of 4 out of 1024)
|
||||
if (pots[0] < read - tolerance || pots[0] > read + tolerance) {
|
||||
pots[0] = read;
|
||||
Serial.print("pot 0: ");
|
||||
//print value between 0 & 127 like MIDI velocity ;)
|
||||
Serial.print(pots[0]/8);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
//get Y1 of 4051, analog to Y0
|
||||
digitalWrite(s0, HIGH);
|
||||
digitalWrite(s1, LOW);
|
||||
digitalWrite(s1, LOW);
|
||||
read = analogRead(A1);
|
||||
if (pots[1] < read - tolerance || pots[1] > read + tolerance) {
|
||||
pots[1] = read;
|
||||
Serial.print("pot 1: ");
|
||||
Serial.print(pots[1]/8);
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
#include <Wire.h>
|
||||
|
||||
#include <bombatuino_INPUT_MCP23017.h>
|
||||
#include <bombatuino_INPUT_74HC4051.h>
|
||||
#include <bombatuino_ROTARY_ENCODER.h>
|
||||
|
||||
INPUT_MCP23017 input_MCP23017_0;
|
||||
INPUT_MCP23017 input_MCP23017_1;
|
||||
INPUT_MCP23017 input_MCP23017_3;
|
||||
INPUT_MCP23017 input_MCP23017_4;
|
||||
|
||||
INPUT_74HC4051 input_4051_A0;
|
||||
INPUT_74HC4051 input_4051_A1;
|
||||
INPUT_74HC4051 input_4051_A2;
|
||||
|
||||
|
||||
ROTARY_ENCODER re_jogwheel(jogwheel);
|
||||
//ROTARY_ENCODER re_JogWheel1(rotaryLeftJogWheel1,rotaryRightJogWheel1);
|
||||
//ROTARY_ENCODER re_JogWheel2(rotaryLeftJogWheel2,rotaryRightJogWheel2);
|
||||
//ROTARY_ENCODER re_Browse(rotaryLeftBrowse,rotaryRightBrowse);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
input_MCP23017_0.begin(0,digitalCallback);
|
||||
input_MCP23017_1.begin(1,digitalCallback);
|
||||
input_MCP23017_3.begin(3,digitalCallback);
|
||||
input_MCP23017_4.begin(4,digitalCallback);
|
||||
|
||||
input_4051_A0.begin(A0,8,9,10,analogCallback);
|
||||
input_4051_A1.begin(A1,8,9,10,analogCallback);
|
||||
input_4051_A2.begin(A2,8,9,10,analogCallback);
|
||||
}
|
||||
|
||||
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 analogCallback(int id, int pin, int value) {
|
||||
Serial.print("id ");
|
||||
Serial.print(pin);
|
||||
Serial.print(" pin ");
|
||||
Serial.print(pin);
|
||||
Serial.print(" : ");
|
||||
Serial.print(value);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void digitalCallback(int id, int pin, int value) {
|
||||
if (id == 1 && pin == 6)
|
||||
re_jogwheel.setPinA(value);
|
||||
if (id == 1 && pin == 7)
|
||||
re_jogwheel.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)) {
|
||||
Serial.print("id ");
|
||||
Serial.print(pin);
|
||||
Serial.print(" pin ");
|
||||
Serial.print(pin);
|
||||
Serial.print(" : ");
|
||||
Serial.print(value);
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
void jogwheel(int c) {
|
||||
Serial.println(c);
|
||||
}
|
||||
|
||||
//JogWheel1
|
||||
void rotaryLeftJogWheel1() {
|
||||
Serial.println("wheel1 left");
|
||||
}
|
||||
|
||||
void rotaryRightJogWheel1() {
|
||||
Serial.println("wheel1 right");
|
||||
}
|
||||
|
||||
|
||||
//JogWheel2
|
||||
void rotaryLeftJogWheel2() {
|
||||
Serial.println("wheel2 left");
|
||||
}
|
||||
|
||||
void rotaryRightJogWheel2() {
|
||||
Serial.println("wheel2 right");
|
||||
}
|
||||
|
||||
|
||||
//Browse
|
||||
void rotaryLeftBrowse() {
|
||||
Serial.println("wheel3 left");
|
||||
}
|
||||
|
||||
void rotaryRightBrowse() {
|
||||
Serial.println("wheel3 right");
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#include <INPUT_4051.h>
|
||||
|
||||
|
||||
|
||||
INPUT_4051 input_4051(A1,10,9,8,printValue);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
input_4051.setPinCount(2);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
input_4051.loop();
|
||||
}
|
||||
|
||||
void printValue(int pin, int value) {
|
||||
Serial.print("pin");
|
||||
Serial.print(pin);
|
||||
Serial.print(" : ");
|
||||
Serial.print(value/8);
|
||||
Serial.println();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#include <Wire.h>
|
||||
|
||||
//helper to check if a bit is set
|
||||
#define BIT_IS_SET(i, bits) (1 << i & bits)
|
||||
|
||||
//array for inputs on bank a of MCP23017
|
||||
boolean button[8];
|
||||
|
||||
void setup() {
|
||||
//set MIDI bautdrate
|
||||
Serial.begin(31250);
|
||||
//start I2C
|
||||
Wire.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//0x20 hardware address of MCP23017 (A0,A1,A2 to ground)
|
||||
Wire.beginTransmission(0x20);
|
||||
Wire.write(0x12); // set MCP23017 memory pointer to GPIOA address
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom(0x20, 1); // request one byte of data from MCP20317
|
||||
int inputs = Wire.read();
|
||||
delayMicroseconds(10);
|
||||
|
||||
int i;
|
||||
for(i=0;i<8;i++) {
|
||||
//check if button is pressed
|
||||
if (BIT_IS_SET(i,inputs)) {
|
||||
//only send Note-on, when button was not pressed before
|
||||
if(!button[i]) {
|
||||
button[i] = true;
|
||||
midiSignal(144,60+i,115);
|
||||
}
|
||||
} else {
|
||||
//only send Note-off, when button was pressed before
|
||||
if(button[i]) {
|
||||
button[i] = false;
|
||||
midiSignal(128,60+i,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//send MIDI signal through softwareserial
|
||||
void midiSignal(byte b1, byte b2, byte b3) {
|
||||
Serial.write(b1);
|
||||
Serial.write(b2);
|
||||
Serial.write(b2);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
#include <Wire.h>
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
#define IOPOLA 0x02
|
||||
#define GPPUA 0x12
|
||||
#define BIT_IS_SET(i, bits) (1 << i & bits)
|
||||
|
||||
SoftwareSerial MIDI(10,11);
|
||||
|
||||
boolean button[8];
|
||||
|
||||
void setup()
|
||||
{
|
||||
//printing baudrate
|
||||
Serial.begin(9600);
|
||||
MIDI.begin(31250);
|
||||
Wire.begin();
|
||||
Wire.beginTransmission(0x20);
|
||||
Wire.write(0x12); // set MCP23017 memory pointer to GPIOB address
|
||||
Wire.write(0xFF); //PULLUP
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Wire.beginTransmission(0x20);
|
||||
Wire.write(0x12); // set MCP23017 memory pointer to GPIOB address
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom(0x20, 1); // request one byte of data from MCP20317
|
||||
int inputs = Wire.read();
|
||||
delayMicroseconds(10);
|
||||
//check if button is pressed
|
||||
|
||||
int i;
|
||||
for(i=0;i<8;i++) {
|
||||
if (BIT_IS_SET(i,inputs)) {
|
||||
if(!button[i]) {
|
||||
button[i] = true;
|
||||
midiSignal(144,60+i,115);
|
||||
}
|
||||
} else {
|
||||
if(button[i]) {
|
||||
button[i] = false;
|
||||
midiSignal(128,60+i,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//send MIDI signal through softwareserial
|
||||
void midiSignal(byte b1, byte b2, byte b3) {
|
||||
Serial.print(b1);
|
||||
Serial.print(" ");
|
||||
Serial.print(b2);
|
||||
Serial.print(" ");
|
||||
Serial.print(b3);
|
||||
Serial.print(" ");
|
||||
Serial.println();
|
||||
MIDI.write(b1);
|
||||
MIDI.write(b2);
|
||||
MIDI.write(b2);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
MIDI note player
|
||||
|
||||
This sketch shows how to use the serial transmit pin (pin 1) to send MIDI note data.
|
||||
If this circuit is connected to a MIDI synth, it will play
|
||||
the notes F#-0 (0x1E) to F#-5 (0x5A) in sequence.
|
||||
|
||||
|
||||
The circuit:
|
||||
* digital in 1 connected to MIDI jack pin 5
|
||||
* MIDI jack pin 2 connected to ground
|
||||
* MIDI jack pin 4 connected to +5V through 220-ohm resistor
|
||||
Attach a MIDI cable to the jack, then to a MIDI synth, and play music.
|
||||
|
||||
created 13 Jun 2006
|
||||
modified 13 Aug 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/Midi
|
||||
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
// Set MIDI baud rate:
|
||||
Serial.begin(9600);
|
||||
pinMode(2, INPUT);
|
||||
digitalWrite(2, HIGH);
|
||||
pinMode(3, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
button();
|
||||
}
|
||||
|
||||
void button() {
|
||||
int sensorVal = digitalRead(2);
|
||||
if (sensorVal == HIGH) {
|
||||
digitalWrite(3, LOW);
|
||||
}
|
||||
else {
|
||||
digitalWrite(3, HIGH);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int val = analogRead(5);
|
||||
Serial.println(val);
|
||||
delay(100); // we have to make a delay to avoid overloading the serial port
|
||||
}
|
||||
Reference in New Issue
Block a user