Alright thank you for the explanation, I've been playing about. Realised I forgot to change the lows back to highs and the highs back to lows. Because I'm not using the pedals at the moments. Just using a push button. It is almost working but there is something not quite right. I have the common cathodes connected now. it first lights up red then when the button is pressed flashes green when it should switch to green and stay lit. But if I continue to click the button it will switch from each colour every now and then. This is what I have got
include
SoftwareSerial midi(0,1); ///RX TX
int latchPin = 5;
int clockPin = 6;
int dataPin = 4;
int modebtn = 7;
byte leds = 0;
int toggle8 = 0;
int mode = 0;
void setup(){
leds = 0; /* set the leds initially all off */
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode (modebtn, INPUT_PULLUP);
midi.begin(31250);
}
void loop(){
if (digitalRead(modebtn) == HIGH && toggle8 == 0){
}
toggle8 = 1;
if(mode == 0){
midi.write(0x90);
midi.write(0x17);
midi.write(0x01);
// delay(300);
}
if(mode == 1){
midi.write(0x90);
midi.write(0x30);
midi.write(0x01);
// delay(300);
}
if (digitalRead(modebtn) == LOW && toggle8 == 1){
toggle8 = 0;
if(mode == 0){
mode = 1;
midi.write(0x90);
midi.write(0x17);
midi.write((byte)0x00);
bitSet(leds, 7); /* turn on red led */
bitClear(leds, 6); /* turn off green led */
updateShiftRegister();
}
else if(mode == 1){
mode = 0;
midi.write(0x90);
midi.write(0x30);
midi.write((byte)0x00);
bitClear(leds, 7); /* turn off the red led */
bitSet(leds, 6); /* turn on the green led */
updateShiftRegister();}
}
}
void updateShiftRegister()
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, leds);
digitalWrite(latchPin, HIGH);
}