Midi with 4021

Hello!

I’ve made an experimental setup for the 4021 shift-register. I would use the “MIDI With Two 4021s” (http://milkcrate.com.au/_other/downloads/projects/midi_with_two_4021s/MIDI_With_Two_4021s.txt) programm from little-scale to test it, but when i want to compile it, i always get the error you can see below. What’s the problem?

/*
MIDI With Two 4021s

by Sebastian Tomczak 
14 May 2008
*/


// MIDI variables
int baud = 31250; 
byte switchVar1 = 0;  
byte switchVar2 = 0; 
byte MIDI_channel = 0x00;
byte MIDI_nibble = 0x90;
byte MIDI_pitches_offset = 60;
byte MIDI_on_velocity = 127;
byte shadows[] = {
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};

// 4021 Pins
int latchPin = 8;
int dataPin = 9;
int clockPin = 7;



// Setup
void setup() {
  Serial.begin(baud);
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT); 
  pinMode(dataPin, INPUT);
}



// Main Program
void loop() {
  digitalWrite(latchPin, 1);
  delayMicroseconds(20);
  digitalWrite(latchPin, 0);
  switchVar1 = shiftIn(dataPin, clockPin);
  switchVar2 = shiftIn(dataPin, clockPin);
  midiShadows(switchVar1, 0);
  midiShadows(switchVar2, 8);
  delay(5);
}



// Functions
byte shiftIn(int myDataPin, int myClockPin) { 
  int i;
  int temp = 0;
  int pinState;
  byte myDataIn = 0;
  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, INPUT);
  for (i=7; i>=0; i--)
  {
    digitalWrite(myClockPin, 0);
    delayMicroseconds(2);
    temp = digitalRead(myDataPin);
    if (temp) {
      pinState = 1;
      myDataIn = myDataIn | (1 << i);
    }
    else {
      pinState = 0;
    }
    digitalWrite(myClockPin, 1);
  }
  return myDataIn;
}

void midiShadows (byte data_byte, int i_init) {
  for(int i = i_init; i < (i_init + 8); i ++) {
    if(shadows[i] !=  (data_byte & (1 << i))) {
      shadows[i] = data_byte & (1 << i); 
      if((switchVar1 & (1 << i)) == 1)
      {
        printByte(MIDI_channel + MIDI_nibble);
        printByte(MIDI_pitches_offset + i_init + i);
        printByte(MIDI_on_velocity);
      }
      if((data_byte & (1 << i)) == 0)
      {
        printByte(MIDI_channel + MIDI_nibble);
        printByte(MIDI_pitches_offset + i_init + i);
        printByte(0);
      }
    }
  }
}

You have no function called printByte, therefore a call to printByte will casue an error.

Try using Serial.print() instead of printByte.

I remember that printByte works with some earlier versions of Arduino.