I have been looking around for the tutorials that I used to study. I am having a little trouble finding them and I don't understand the new ones. I apologize if my questions may seem to be beginner stuff. On Linux C programming for terminal based programs the "printf" item uses a conversion character to insert a variable int into a string. How is this done for the liquidcrystal.h library?
My code is currently as fallows
#include <MIDI.h> // Add Midi Library
#include <LiquidCrystal.h>
//Create an instance of the library with default name, serial port and settings
MIDI_CREATE_DEFAULT_INSTANCE();
// Create an LCD object. Parameters: (RS, E, D4, D5, D6, D7):
LiquidCrystal lcd = LiquidCrystal(2, 3, 4, 5, 6, 7);
void setup() {
MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize the Midi Library.
// OMNI sets it to listen to all channels.. MIDI.begin(2) would set it
// to respond to notes on channel 2 only.
MIDI.setHandleNoteOn(MyHandleNoteOn); // This is important!! This command
// tells the Midi Library which function you want to call when a NOTE ON command
// is received. In this case it's "MyHandleNoteOn".
MIDI.setHandleNoteOff(MyHandleNoteOff); // This command tells the Midi Library
// to call "MyHandleNoteOff" when a NOTE OFF command is received.
// Specify the LCD's number of columns and rows. Change to (20, 4) for a 20x4 LCD:
lcd.begin(16, 2);
// Set the cursor on the third column and the first row, counting starts at 0:
lcd.setCursor(4, 0);
// Print the string '16x2 LCD':
lcd.print("16x2 LCD");
// Set the cursor on the third column and the second row:
lcd.setCursor(2, 1);
// Print the string 'Hello World!':
lcd.print("Hello World!");
}
void loop() { // Main loop
MIDI.read(); // Continuously check if Midi data has been received.
}
// MyHandleNoteON is the function that will be called by the Midi Library
// when a MIDI NOTE ON message is received.
// It will be passed bytes for Channel, Pitch, and Velocity
void MyHandleNoteOn(byte channel, byte pitch, byte velocity) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.write("Channel is", " ", channel, "Pitch is", " ", pitch, "Velocity is", " ", velocity" );
}
// MyHandleNoteOFF is the function that will be called by the Midi Library
// when a MIDI NOTE OFF message is received.
// * A NOTE ON message with Velocity = 0 will be treated as a NOTE OFF message *
// It will be passed bytes for Channel, Pitch, and Velocity
void MyHandleNoteOff(byte channel, byte pitch, byte velocity) {
}
I am mashing together NotesNVolts with example code for a traditional LCD on 4 data lines. I would like to use 8 bits instead of 4, but I think it would be better if I did this one step at a time. First off I would like a point in the correct direction for working with the variables Channel, Note, and Velocity. I will be setting this up with sample hold circiuts using the 742 operational amplifier. My idea is to use the onboard pulse width modulation pins to set a control voltage value. Then this can be patched to a voltage controlled oscilator and other synthesizer modules. This entire project is a work in progress and it will be a lot more complex then your raditional MIDI to CV module you would buy from say ummm.... Synthrotek.
Thanks for any help you guys can give. I will be sure to make all this into a tutorial for a simplistic design. The advanced polished design will be on normal Atmel chips without an arduino boot loader. This advanced version will be in my non-fiction book series. Rest assured the basic design will be available to anyone who would like to use the schematics and open source code for their own purposes.