Hello everyone, I am trying to build a daw controller using arduino. I am starting using only one button but got problems transfering the data through bluetooth.
This is my code:
/*LIBRARIES*/
#include <MIDI.h>
#include <SoftwareSerial.h>
#include <Bounce2.h>
/*GLOBAL VARIABLES*/
MIDI_CREATE_DEFAULT_INSTANCE();
int pinButton1 = 2; int button1State; int lastButton1State; Bounce Button1 = Bounce();
int bounceDelay = 5;
SoftwareSerial Bth(0, 1);
void setup() {
MIDI.begin();
Serial.begin(57600);
pinMode(pinButton1, INPUT); Button1.attach(pinButton1); Button1.interval(bounceDelay);
Bth.begin(57600);
}
void loop() {
Button1.update(); button1State = Button1.read();
if(button1State != lastButton1State){
if(button1State == LOW){
MIDI.sendNoteOn(49, 127, 1);
delay(100);
MIDI.sendNoteOff(49, 0, 1);
}
lastButton1State = button1State;
}
}
Please help me improve the code or delete anything unnecessary
When I press the button this message appears:
-Warning: got a status byte when we were expecting 3 more data bytes, sending possibly incomplete MIDI message 0xff
-Serial In: System Message #3: %2
How does the MIDI library know where to send the MIDI message?
It doesn’t know you want to send it through the software serial port.
It is sent through the serial port so how come it is sending you messages back?
You have not described your setup adequately enough. Do you have Hairless running on your computer? What baud rate have you set it to?
What Arduino do you have? Why are you using the hardware serial pins for the software serial port?
Grumpy_Mike:
How does the MIDI library know where to send the MIDI message?
It doesn’t know you want to send it through the software serial port.
It is sent through the serial port so how come it is sending you messages back?
You have not described your setup adequately enough. Do you have Hairless running on your computer? What baud rate have you set it to?
What Arduino do you have? Why are you using the hardware serial pins for the software serial port?
Can you help me by telling what to correct in the code?
Yes I am running hairless in the same baud rate(57600). I am using arduino uno, but in the final project I will use a board I made with ATmega328p. I have to use pins 0 and 1 for RX,TX since thats how i have printed my circuit.
Can you help me by telling what to correct in the code?
Well not really until I know
-
what you want that code to do
-
what hardware you have and how you have wired it up. You mention a home made PCB, what schematic did you use for making this?
I have to use pins 0 and 1 for RX,TX since thats how i have printed my circuit.
You can not use software serial like this. You might have to get the scalpel out and cut some tracks.
Grumpy_Mike:
Well not really until I know
-
what you want that code to do
-
what hardware you have and how you have wired it up. You mention a home made PCB, what schematic did you use for making this?
You can not use software serial like this. You might have to get the scalpel out and cut some tracks.
First of all thank you for your interest.
1)Whenever you press the button to play the noce C(I think value 49), so when I will have more buttons I can play melodies and use it like a pad.
2) I am using a normal tactile push button where one side is connected to +5V and the other to digital pin 2 and to ground through a 10kΩ resistor(i dont have a schematic, but i think it is too simple). I am not using a custom pcb while I am prototyping, just arduino uno.
3) So it is not possible to tranfer the data through bluetooth using Tx and Rx of pins D0-D1 ?
1)Whenever you press the button to play the noce C(I think value 49), so when I will have more buttons I can play melodies and use it like a pad.
Yes BUT what is that code trying to do. You seem to have two routes into the PC to trigger MIDI, you can only do one at a time so which is it you want that code to do?
- I am using a normal tactile push button .....
Wrong way round really. See http://www.thebox.myzen.co.uk/Tutorial/Inputs.html. The best way is to use a pull up and connect to ground.
- So it is not possible to tranfer the data through bluetooth using Tx and Rx of pins D0-D1 ?
It is but not at the same time as you use it to talk to the serial port in the Arduino.