Skip to content

Instantly share code, notes, and snippets.

@Klepvink
Created February 3, 2022 18:55
Show Gist options
  • Save Klepvink/1614b7cb7db3bd2d5eb9816905fded54 to your computer and use it in GitHub Desktop.
Save Klepvink/1614b7cb7db3bd2d5eb9816905fded54 to your computer and use it in GitHub Desktop.
Python scripts that puts a rainbow fade on the novation launchkey 25 MK2 LED-lights. Original script was written by David Madison (https://www.partsnotincluded.com/how-to-control-the-leds-on-a-novation-launchkey-mini-ii/)
#
# Launchkey Mini II Sweep Animation
# by David Madison © 2018
# www.partsnotincluded.com
#
#
# Modified to work for the Launchkey 25 MK2.
# Instead of the original sweep, it now displays
# a looping rainbow fade.
# Modifications by Klepvink
# https://github.com/Klepvink
#
import mido
from time import sleep
# Colors, numbers for the LED's and further information are
# obtained via the MK2 Programmers Reference guide written
# by Danny Nugent. See https://resource.novationmusic.com/sites/default/files/novation/downloads/10535/launchkey-mk2-programmers-reference-guide.pdf
chunk1 = (40, 41, 36, 37)
chunk2 = (42, 43, 38, 39)
chunk3 = (48, 49, 44, 45)
chunk4 = (50, 51, 46, 47)
row1 = (40, 41, 42, 43, 48, 49, 50, 51)
row2 = (36, 37, 38, 39, 44, 45, 46, 47)
all_rows = row1 + row2
all_leds = chunk1 + chunk2 + chunk3 + chunk4
def write_led(led_id, color_vel):
midi_out.send(mido.Message('note_on', channel=15,
note=led_id, velocity=color_vel))
if __name__ == "__main__":
try:
# Launchkey InControl port
midi_out = mido.open_output("MIDIOUT2 (3- Launchkey MK2 25) 2")
# Switch to "InControl" mode
midi_out.send(mido.Message.from_bytes([0x90, 0x0C, 0x7F]))
while True:
# This list represents the colors of the rainbow fade.
for i in [5, 72, 84, 9, 96, 109, 13, 12, 73, 75, 87, 89, 90, 36, 37, 44, 41, 45, 46, 49, 48, 52, 53]:
for index, led in enumerate(row1):
# Set current LED color
write_led(row1[index], i)
write_led(row2[index], i)
# Edit this sleep statement for a more calm fade. Im personally a fan of the whole rave party vibe
sleep(0.008)
except KeyboardInterrupt:
pass
for led in all_leds:
write_led(led, 0) # Turn off all LEDs
# Disable "InControl" mode
midi_out.send(mido.Message.from_bytes([0x90, 0x0C, 0x00]))
midi_out.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment