Hi guys
i did a pcb layout to the scheme from aleph site, it looks very easy to make.
i was wandering if any one here can help me to add to the code a GATE from pin 15 (digital pin 9 PWM) on the arduino chip, I didn't wrote the code, I copy and past it as it is in his site.
as you will see in the layout from pin 15 there is out to the Gate but i'm (assuming i will have angate out from that pin), im gusseing it will be only 5V Gate, so i took the help from the x0xb0x forum (thanks Guest ) and did what guest told me, i just multiplyed the 5V to 12V the same as the x0x does.
i hope you guys can help me adding the Gate from the 15 pin on the chip. the goal is when i press the midi keyboards i'll get CV and Gate and not only a cv out.
anyway...this is the code...
byte incomingByte;
byte note;
byte velocity;
int pwm = 6;
int statusLed = 13; // select the pin for the LED
int action = 2; //0 =note off ; 1=note on ; 2= nada
//setup: declaring iputs and outputs and begin serial
void setup() {
pinMode(pwm, OUTPUT);
analogWrite(pwm, 0);
setPwmFrequency(pwm, 8);
pinMode(statusLed, OUTPUT); // declare the LED's pin as output
//start serial with midi baudrate 31250 or 38400 for debugging
Serial.begin(31250);
//digitalWrite(statusLed, HIGH);
}
//loop: wait for serial data, and interpret the message
void loop () {
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
//Serial.print(incomingByte); Serial.println('///');
// wait for as status-byte, channel 1, note on or off
if (incomingByte== 144){ // note on message starting starting
action=1;
}else if (incomingByte== 128){ // note off message starting
action=0;
}else if (incomingByte== 208){ // aftertouch message starting
//not implemented yet
}else if (incomingByte== 160){ // polypressure message starting
//not implemented yet
}else if ( (action==0)&&(note==0) ){ // if we received a "note off", we wait for which note (databyte)
note=incomingByte;
playNote(note, 0);
note=0;
velocity=0;
action=2;
}else if ( (action==1)&&(note==0) ){ // if we received a "note on", we wait for the note (databyte)
note=incomingByte;
}else if ( (action==1)&&(note!=0) ){ // ...and then the velocity
velocity=incomingByte;
playNote(note, velocity);
note=0;
velocity=0;
action=0;
}else{
//nada
}
}
}
////////////////////////////////////////??? ??
void playNote(byte note, byte velocity){
int value;
//since we don't want to "play" all notes we wait for a note between 36 & 44
value = (note - 20.6) * 0.083 / 5 * 255;
if(velocity == 0) value = 0;
analogWrite(pwm, value);
Blink();
}
void setPwmFrequency(int pin, int divisor)
{
byte mode;
if(pin == 5 || pin == 6 || pin == 9 || pin == 10)
{
switch(divisor)
{
case 1: mode = 0x01; break;
case 8: mode = 0x02; break;
case 64: mode = 0x03; break;
case 256: mode = 0x04; break;
case 1024: mode = 0x05; break;
default: return;
}
if(pin == 5 || pin == 6)
{
TCCR0B = TCCR0B & 0b11111000 | mode;
}
else
{
TCCR1B = TCCR1B & 0b11111000 | mode;
}
}
else if(pin == 3 || pin == 11)
{
switch(divisor)
{
case 1: mode = 0x01; break;
case 8: mode = 0x02; break;
case 32: mode = 0x03; break;
case 64: mode = 0x04; break;
case 128: mode = 0x05; break;
case 256: mode = 0x06; break;
case 1024: mode = 0x7; break;
default: return;
}
TCCR2B = TCCR2B & 0b11111000 | mode;
}
}
void Blink()
{
digitalWrite(statusLed, HIGH);
delay(50);
digitalWrite(statusLed, LOW);
delay(50);
}
i thank you in advance for the help.