Skip to content

Instantly share code, notes, and snippets.

@ianoxley
Created August 21, 2012 17:56
Show Gist options
  • Save ianoxley/3417873 to your computer and use it in GitHub Desktop.
Save ianoxley/3417873 to your computer and use it in GitHub Desktop.
Smoke on the Water for Lego Mindstorms
#!/usr/bin/env python
#
# Smoke on the water by Deep Purple, for the Lego Mindstorms
#
# Note frequencies worked out as follows:
# A = 440
# Notes above A = A * (1.059463)^ no. of steps above A
# Notes below A = A * (1.059463)^ -no. of steps below A
#
from time import sleep
import nxt.locator
FREQ_A = 440
FREQ_G = 392
FREQ_B_FLAT = 466
FREQ_C = 523
FREQ_C_SHARP = 554
b = nxt.locator.find_one_brick(name='NXT')
for i in range(1, 3):
b.play_tone_and_wait(FREQ_G, 200)
sleep(0.25)
b.play_tone_and_wait(FREQ_B_FLAT, 200)
sleep(0.25)
b.play_tone_and_wait(FREQ_C, 500)
sleep(0.25)
b.play_tone_and_wait(FREQ_G, 200)
sleep(0.25)
b.play_tone_and_wait(FREQ_B_FLAT, 200)
sleep(0.25)
b.play_tone_and_wait(FREQ_C_SHARP, 150)
sleep(0.5)
b.play_tone_and_wait(FREQ_C, 650)
sleep(0.25)
b.play_tone_and_wait(FREQ_G, 200)
sleep(0.25)
b.play_tone_and_wait(FREQ_B_FLAT, 200)
sleep(0.25)
b.play_tone_and_wait(FREQ_C, 500)
sleep(0.25)
b.play_tone_and_wait(FREQ_B_FLAT, 200)
sleep(0.25)
b.play_tone_and_wait(FREQ_G, 1000)
sleep(0.4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment