diff --git a/.clang_complete b/.clang_complete deleted file mode 100644 index 07bf2b3..0000000 --- a/.clang_complete +++ /dev/null @@ -1,30 +0,0 @@ --I/home/nathan/.platformio/packages/framework-arduinoavr/cores/arduino --I/home/nathan/.platformio/packages/framework-arduinoavr/variants/micro --I/home/nathan/.platformio/lib/MIDI controller/src --I/home/nathan/.platformio/lib/MIDIUSB_ID1104/src --I/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/SoftwareSerial/src --I/home/nathan/.platformio/lib/ArduinoJson_ID64/src --I/home/nathan/.platformio/lib/Keypad_ID165/src --I/home/nathan/.platformio/lib/PubSubClient_ID89/src --I/home/nathan/.platformio/lib/Tone_ID1420 --I/home/nathan/.platformio/lib/WifiManager_ID567 --I/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/EEPROM/src --I/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/HID/src --I/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/SPI/src --I/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/Wire/src --I/home/nathan/.platformio/packages/toolchain-atmelavr/avr/include --I/home/nathan/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include-fixed --I/home/nathan/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include --I/home/nathan/.platformio/packages/tool-unity --I/media/c/Users/Nathan/Documents/PlatformIO/Projects/MidiKeyboard/include --I/media/c/Users/Nathan/Documents/PlatformIO/Projects/MidiKeyboard/src --DPLATFORMIO=40000 --DARDUINO_AVR_MICRO --DF_CPU=16000000L --DARDUINO_ARCH_AVR --DARDUINO=10805 --DUSB_VID=0x2341 --DUSB_PID=0x0037 --DUSB_PRODUCT="Arduino Micro" --DUSB_MANUFACTURER="Arduino" --D__AVR_ATmega32U4__ diff --git a/.directory b/.directory deleted file mode 100644 index e29bf20..0000000 --- a/.directory +++ /dev/null @@ -1,6 +0,0 @@ -[Dolphin] -Timestamp=2019,2,5,20,24,51 -Version=4 - -[Settings] -HiddenFilesShown=true diff --git a/.gcc-flags.json b/.gcc-flags.json deleted file mode 100644 index 115b9c4..0000000 --- a/.gcc-flags.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "execPath": "/home/nathan/.platformio/packages/toolchain-atmelavr/bin/avr-g++", - "gccDefaultCFlags": "-fsyntax-only -std=gnu11 -fno-fat-lto-objects -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega32u4 -DPLATFORMIO=40000 -DARDUINO_AVR_MICRO -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO=10805 -DUSB_VID=0x2341 -DUSB_PID=0x0037 -DUSB_PRODUCT=\"Arduino Micro\" -DUSB_MANUFACTURER=\"Arduino\" -D__AVR_ATmega32U4__", - "gccDefaultCppFlags": "-fsyntax-only -fno-exceptions -fno-threadsafe-statics -fpermissive -std=gnu++11 -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega32u4 -DPLATFORMIO=40000 -DARDUINO_AVR_MICRO -DF_CPU=16000000L -DARDUINO_ARCH_AVR -DARDUINO=10805 -DUSB_VID=0x2341 -DUSB_PID=0x0037 -DUSB_PRODUCT=\"Arduino Micro\" -DUSB_MANUFACTURER=\"Arduino\" -D__AVR_ATmega32U4__", - "gccErrorLimit": 15, - "gccIncludePaths": "/home/nathan/.platformio/packages/framework-arduinoavr/cores/arduino,/home/nathan/.platformio/packages/framework-arduinoavr/variants/micro,/home/nathan/.platformio/lib/MIDI controller/src,/home/nathan/.platformio/lib/MIDIUSB_ID1104/src,/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/SoftwareSerial/src,/home/nathan/.platformio/lib/ArduinoJson_ID64/src,/home/nathan/.platformio/lib/Keypad_ID165/src,/home/nathan/.platformio/lib/PubSubClient_ID89/src,/home/nathan/.platformio/lib/Tone_ID1420,/home/nathan/.platformio/lib/WifiManager_ID567,/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/EEPROM/src,/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/HID/src,/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/SPI/src,/home/nathan/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/Wire/src,/home/nathan/.platformio/packages/toolchain-atmelavr/avr/include,/home/nathan/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include-fixed,/home/nathan/.platformio/packages/toolchain-atmelavr/lib/gcc/avr/5.4.0/include,/home/nathan/.platformio/packages/tool-unity,/media/c/Users/Nathan/Documents/PlatformIO/Projects/MidiKeyboard/include,/media/c/Users/Nathan/Documents/PlatformIO/Projects/MidiKeyboard/src", - "gccSuppressWarnings": false -} diff --git a/build.log b/build.log deleted file mode 100644 index 1693750..0000000 --- a/build.log +++ /dev/null @@ -1,18 +0,0 @@ -Processing micro (platform: atmelavr; board: micro; framework: arduino) -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -Verbose mode can be enabled via `-v, --verbose` option -CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/micro.html -PLATFORM: Atmel AVR > Arduino Micro -HARDWARE: ATMEGA32U4 16MHz 2.50KB RAM (28KB Flash) -Library Dependency Finder -> http://bit.ly/configure-pio-ldf -LDF MODES: FINDER(chain) COMPATIBILITY(soft) -Collected 12 compatible libraries -Scanning dependencies... -Dependency Graph -|-- 3.1.0 #e895a51 -| |-- 1.0.3 -| |-- 1.0 -Compiling .pioenvs/micro/src/main.cpp.o -Compiling .pioenvs/micro/lib7af/MIDI controller/MIDI_Outputs/Digital.cpp.o -Compiling .pioenvs/micro/lib7af/MIDI controller/MIDI_Outputs/DigitalCC.cpp.o -Compiling .pioenvs/micro/lib7af/MIDI controller/MIDI_Outputs/DigitalLatch.cpp.o diff --git a/platformio.ini b/platformio.ini index 6a12cbd..4bb6a61 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,11 +9,13 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -default_envs = micro_debug +default_envs = micro [env] build_flags = -Wall lib_deps = + SPI + Adafruit MPR121 Control Surface MIDIUSB @@ -21,8 +23,15 @@ lib_deps = platform = atmelavr board = micro framework = arduino +board_build.f_cpu = 16000000L -[env:micro_debug] +[env:debug] +platform = atmelavr build_type = debug extends = env:micro -build_flags = -D DEBUG_MAIN \ No newline at end of file + +[env:matrix] +platform = atmelavr +build_type = debug +extends = env:micro +build_flags = -D DEBUG_MATRIX diff --git a/res/doc/MPR121.pdf b/res/doc/MPR121.pdf new file mode 100644 index 0000000..509518d Binary files /dev/null and b/res/doc/MPR121.pdf differ diff --git a/res/doc/MidiKeyboard.fzz b/res/doc/MidiKeyboard.fzz index 31ea7ef..e3899c5 100644 Binary files a/res/doc/MidiKeyboard.fzz and b/res/doc/MidiKeyboard.fzz differ diff --git a/res/doc/MidiKeyboard_bb.png b/res/doc/MidiKeyboard_bb.png new file mode 100644 index 0000000..eeb764f Binary files /dev/null and b/res/doc/MidiKeyboard_bb.png differ diff --git a/res/doc/cd74hc4067.pdf b/res/doc/cd74hc4067.pdf new file mode 100644 index 0000000..fa09f8d Binary files /dev/null and b/res/doc/cd74hc4067.pdf differ diff --git a/res/doc/sn74hc595.pdf b/res/doc/sn74hc595.pdf new file mode 100644 index 0000000..cb869ac Binary files /dev/null and b/res/doc/sn74hc595.pdf differ diff --git a/src/main.cpp b/src/main.cpp index 35197c8..0023f94 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,18 +1,22 @@ #include +#include +#include #define s * 1000 -#ifndef DEBUG_MAIN -#include -#define NOTE_ON_CMD 0x90 -#define NOTE_OFF_CMD 0x80 #define NOTE_VELOCITY 127 +#define ON 127 +#define OFF 0 - +#ifndef __PLATFORMIO_BUILD_DEBUG__ // Instantiate a MIDI Interface to use -// USBMIDI_Interface midi; +USBMIDI_Interface midi; +#else /* __PLATFORMIO_BUILD_DEBUG__ */ // Instantiate a MIDI Interface to use USBDebugMIDI_Interface midi{115200}; +#endif /* __PLATFORMIO_BUILD_DEBUG__ */ + +Channel channel{CHANNEL_2}; /* Pins */ /* GPIO (I2C) */ @@ -33,209 +37,159 @@ const uint8_t shift_clock{1}; const uint8_t keyboard_in[KEYBOARD_INSIZE]{4, 5, 6, 7, 8, 9}; /* Components */ +/* CapaSensor (I2C) */ +Adafruit_MPR121 capa_sensor = Adafruit_MPR121(); /* GPIO (I2C) */ /* Multiplexer */ CD74HC4067 multiplexer{mux_sig, mux_addr, mux_en}; /* ShiftRegister (OUT) */ -ShiftRegisterOut<2> shiftRegister(shift_data, shift_clock, shift_latch, MSBFIRST); +// ShiftRegisterOut<2> shiftRegister(shift_data, shift_clock, shift_latch, MSBFIRST); /* keyboard (IN) */ -/* Midi links */ -// USBDebugMIDI_Interface midiInterface(115200); - CCPotentiometer potentiometers[] = { - {multiplexer.pin(0), {MIDI_CC::Channel_Volume, CHANNEL_1}}, - {multiplexer.pin(1), {MIDI_CC::Channel_Volume, CHANNEL_2}}, - {multiplexer.pin(2), {MIDI_CC::Channel_Volume, CHANNEL_3}}, - {multiplexer.pin(3), {MIDI_CC::Channel_Volume, CHANNEL_4}}, - {multiplexer.pin(4), {MIDI_CC::Channel_Volume, CHANNEL_5}}, - {multiplexer.pin(5), {MIDI_CC::Channel_Volume, CHANNEL_6}}, - {multiplexer.pin(6), {MIDI_CC::Channel_Volume, CHANNEL_7}}, - {multiplexer.pin(7), {MIDI_CC::Channel_Volume, CHANNEL_8}}, - {multiplexer.pin(8), {MIDI_CC::Channel_Volume, CHANNEL_9}}, - {multiplexer.pin(9), {MIDI_CC::Channel_Volume, CHANNEL_10}}, + {multiplexer.pin(0), {1, channel}}, + {multiplexer.pin(1), {2, channel}}, + {multiplexer.pin(2), {3, channel}}, + {multiplexer.pin(3), {4, channel}}, + {multiplexer.pin(4), {5, channel}}, + {multiplexer.pin(5), {6, channel}}, + {multiplexer.pin(6), {7, channel}}, + {multiplexer.pin(7), {8, channel}}, + {multiplexer.pin(8), {9, channel}}, + {multiplexer.pin(9), {10, channel}}, }; byte matrix[16][6][2] = { -/*00*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, -/*01*/ {{1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}}, -/*02*/ {{1, 6}, {1, 7}, {1, 8}, {1, 9}, {1, 10}, {1, 11}}, -/*03*/ {{1, 18}, {1, 19}, {1, 20}, {1, 21}, {1, 22}, {1, 23}}, -/*04*/ {{1, 47}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, -/*05*/ {{1, 41}, {1, 42}, {1, 43}, {1, 44}, {1, 45}, {1, 46}}, -/*06*/ {{1, 36}, {1, 37}, {1, 38}, {1, 39}, {1, 40}, {1, 40}}, -/*07*/ {{1, 30}, {1, 31}, {1, 32}, {1, 33}, {1, 34}, {1, 35}}, -/*08*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, -/*09*/ {{1, 24}, {1, 25}, {1, 26}, {1, 27}, {1, 28}, {1, 29}}, -/*10*/ {{1, 12}, {1, 13}, {1, 14}, {1, 15}, {1, 16}, {1, 17}}, -/*11*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, -/*12*/ {{2, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, -/*13*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, -/*14*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, -/*15*/ {{2, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, +/* 0 | 1 | 2 | 3 | 4 | 5 */ +/*0*/ {{1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}}, +/*1*/ {{1, 6}, {1, 7}, {1, 8}, {1, 9}, {1, 10}, {1, 11}}, +/*2*/ {{1, 18}, {1, 19}, {1, 20}, {1, 21}, {1, 22}, {1, 23}}, +/*3*/ {{1, 48}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, +/*4*/ {{1, 42}, {1, 43}, {1, 44}, {1, 45}, {1, 46}, {1, 47}}, +/*5*/ {{1, 36}, {1, 37}, {1, 38}, {1, 39}, {1, 40}, {1, 41}}, +/*6*/ {{1, 30}, {1, 31}, {1, 32}, {1, 33}, {1, 34}, {1, 35}}, +/*7*/ {{1, 24}, {1, 25}, {1, 26}, {1, 27}, {1, 28}, {1, 29}}, +/*8*/ {{1, 12}, {1, 13}, {1, 14}, {1, 15}, {1, 16}, {1, 17}}, +/*a*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, +/*b*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, +/*c*/ {{2, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, +/*d*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, +/*e*/ {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, +/*f*/ {{2, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, }; -bool ref[6*16]; +bool ref[16][6] = {{false}}; unsigned char shift = 0; void setup() { - // Serial.begin(31250); - // while (Serial.available() == 0){ - // delay(.5 s); - // } - - // Serial.print("Serial OK"); - - midi.begin(); - for (size_t i = 0; i < KEYBOARD_INSIZE; ++i) { ExtIO::pinMode(keyboard_in[i], INPUT); } - for (size_t i = 0; i < 6*16; ++i) { - ref[i] = false; + for (size_t i = 0; i < 16; ++i) { + for (size_t j = 0; j < 6; j++) + { + ref[i][j] = false; + } } - // ExtIO::pinMode(shift_data, OUTPUT); - // ExtIO::pinMode(shift_latch, OUTPUT); - // ExtIO::pinMode(shift_clock, OUTPUT); - shiftRegister.begin(); + + pinMode(shift_data, OUTPUT); + pinMode(shift_latch, OUTPUT); + pinMode(shift_clock, OUTPUT); + + capa_sensor.begin(0x5A); + + Control_Surface.begin(); +} + +void scanPin(int pin); + +void button_matrix_mgt(void); + +void capa_sensor_mgt(void); + +void loop() +{ + button_matrix_mgt(); + + capa_sensor_mgt(); + + Control_Surface.loop(); +} + +void button_matrix_mgt(void) { + for (size_t i = 0; i < 16; ++i) { + scanPin(i); + uint8_t rowValue[KEYBOARD_INSIZE]; + for (size_t j = 0; j < 6; ++j) { + if ((rowValue[i] = ExtIO::digitalRead(keyboard_in[j])) == HIGH) { + if (!ref[i][j]) { +#ifndef DEBUG_MATRIX + byte type = matrix[i][j][0]; + byte key = matrix[i][j][1]; + if (type == 1) { + midi.sendNoteOn({key + shift, channel}, NOTE_VELOCITY); + } else if (type == 2) { + // todo : note off + if (key == 0 && shift >= 12) { + shift -= 12; + } else if (key == 1 && shift <= 0xFF - 47 - 12) { + shift += 12; + } + } +#else /* DEBUG_MATRIX */ + midi.sendNoteOn(i, j); +#endif /* DEBUG_MATRIX */ + ref[i][j] = true; + } + } else { + if (ref[i][j]) { +#ifndef DEBUG_MATRIX + if (matrix[i][j][0] == 1) { + midi.sendNoteOff({matrix[i][j][1] + shift, channel}, NOTE_VELOCITY); + } +#else /* DEBUG_MATRIX */ + midi.sendNoteOff(i, j); +#endif /* DEBUG_MATRIX*/ + ref[i][j] = false; + } + } + } + } +} + +void capa_sensor_mgt(void) { + // Get the currently touched pads + int static lasttouched; + int currtouched = capa_sensor.touched(); + + for (uint8_t i = 0; i < 12; i++) + { + // it if *is* touched and *wasnt* touched before, alert! + if ((currtouched & _BV(i)) && !(lasttouched & _BV(i))) { + midi.sendCC({i, channel}, ON); + } + // if it *was* touched and now *isnt*, alert! + if (!(currtouched & _BV(i)) && (lasttouched & _BV(i))) { + midi.sendCC({i, channel}, OFF); + } + } + + // reset our state + lasttouched = currtouched; } void scanPin(int pin) { - ExtIO::digitalWrite(shift_latch, LOW); - if (pin < 8) { - byte bitsToSend = 0b00000001 << pin; - ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000); - ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, bitsToSend); - } else { - byte bitsToSend = 0b00000001 << (pin - 8); - ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, bitsToSend); - ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000); - } - ExtIO::digitalWrite(shift_latch, HIGH); -} - - -void init_shift() { - ExtIO::digitalWrite(shift_latch, LOW); - ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000); - ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000001); - ExtIO::digitalWrite(shift_latch, HIGH); -} - -void next_shift() { - ExtIO::digitalWrite(shift_data, LOW); - ExtIO::digitalWrite(shift_latch, LOW); - ExtIO::digitalWrite(shift_clock, HIGH); - ExtIO::digitalWrite(shift_clock, LOW); - ExtIO::digitalWrite(shift_latch, HIGH); -} - -void noteOn(byte note); - -void noteOff(byte note); - -void loop() { - init_shift(); - for (size_t i = 0; i < 16; ++i) { - // shiftRegister.digitalWrite(i, HIGH); - uint8_t rowValue[KEYBOARD_INSIZE]; - bool pressed = false; - for (size_t j = 0; j < 6; ++j) { - if ((rowValue[i] = ExtIO::digitalRead(keyboard_in[j])) == HIGH) { - if (!ref[j * 16 + i]) { - byte type = matrix[i][j][0]; - byte key = matrix[i][j][1]; - if (type == 1) { - noteOn(key); - } else if (type == 2) { - if (key == 0 && shift >= 12) { - shift -= 12; - } else if (key == 1 && shift <= 0xFF - 47 - 12) { - shift += 12; - } - } - ref[j * 16 + i] = true; - } - } else { - if (ref[j * 16 + i]) { - if (matrix[i][j][0] == 1) { - noteOff(matrix[i][j][1]); - } - ref[j * 16 + i] = false; - } - } - } - next_shift(); - // shiftRegister.digitalWrite(i, LOW); - // delay(3 s); - } - - // for (uint8_t i = 0; i < 8; ++i) { - // byte bitsToSend = 0b00000001 << i; - // ExtIO::digitalWrite(shift_latch, LOW); - // // ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, bitsToSend); - // // ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000); - // ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b11111111); - // ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b11111111); - // ExtIO::digitalWrite(shift_latch, HIGH); - // Serial.print(" "); - // Serial.print(bitsToSend, BIN); - // Serial.println(" HIGH"); - // delay(4 s); - // //bitWrite(bitsToSend, i, LOW); - // ExtIO::digitalWrite(shift_latch, LOW); - // ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000); - // ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000); - // ExtIO::digitalWrite(shift_latch, HIGH); - // Serial.print(i); - // Serial.println(" LOW"); - // delay(4 s); - // } - - // analogWrite(9, val[0] * 256 / 1024); - - midi.update(); - // MIDI_Controller.refresh(); - // lastLoop = millis() - start; - // loopAverage = (loopAverage + lastLoop) / 2; - //delay(.5 s); -} - - -void noteOn(byte note) { - // MIDI_Controller.MIDI()->send(NOTE_ON_CMD, 0, note + shift, NOTE_VELOCITY); - // Serial.write(NOTE_ON_CMD); - // Serial.write(note + shift); - // Serial.write(NOTE_VELOCITY); - midi.sendNoteOn(note, NOTE_VELOCITY); -} - -void noteOff(byte note) { - // MIDI_Controller.MIDI()->send(NOTE_OFF_CMD, 0, note + shift, NOTE_VELOCITY); - // Serial.write(NOTE_OFF_CMD); - // Serial.write(note + shift); - // Serial.write(NOTE_VELOCITY); - midi.sendNoteOff(note, NOTE_VELOCITY); -} - -#else /* DEBUG_MAIN */ - -void setup() -{ - Serial.begin(115200); - while (Serial.available() == 0){ - delay(.5 s); - } - - Serial.print("Serial OK"); -} - -void loop() { - while (Serial.available() != 0) { - char c = Serial.read(); - Serial.print(c); - } -} -#endif /* DEBUG_MAIN */ \ No newline at end of file + ExtIO::digitalWrite(shift_latch, LOW); + if (pin < 8) { + byte bitsToSend = 0b00000001 << pin; + ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000); + ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, bitsToSend); + } else { + byte bitsToSend = 0b00000001 << (pin - 8); + ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, bitsToSend); + ExtIO::shiftOut(shift_data, shift_clock, MSBFIRST, 0b00000000); + } + ExtIO::digitalWrite(shift_latch, HIGH); +} \ No newline at end of file