ice-king wip

master
ugrnm 5 years ago
parent f3dc42b46f
commit a496029b38

@ -0,0 +1 @@
build-*

@ -0,0 +1,12 @@
# This will only work if you have installed arduino-mk
# And set your shell rc with the following env variables:
#
# export ARDUINO_DIR=/usr/share/arduino
# export ARDMK_DIR=/usr/share/arduino
#
# Adjust to reflect your own paths!
BOARD_TAG = nano328
MONITOR_PORT = /dev/ttyUSB0
include ${ARDMK_DIR}/Arduino.mk

@ -0,0 +1,43 @@
/*
ICE KING
*/
#define POT1 (0)
#define POT2 (1)
#define POT3 (2)
#define SPEAKER (11)
int t;
int u;
int tone_delay;
int tone_freq;
void
setup()
{
Serial.begin(9600); // DEBUG
pinMode(SPEAKER, OUTPUT);
}
void
loop()
{
// 1CE C0DE
t++;
u = (t*t/256)&(t>>((t/1024)%16))^t%64*(0x1CEC0DE>>(t>>9&30)&t%32)*t>>18;
// Use bytebeat u value as tone frequency
// tone(pin, frequency) is provided by Arduino lib
tone_freq = u * (((1023 - analogRead(POT2)) / 10) + 1);
tone(SPEAKER, tone_freq);
// Use pot 1 to set the tone duration (0-31)
//tone_delay = analogRead(POT1) / 32; // meergranen v2
tone_delay = (1023 - analogRead(POT1)) / 32; // meergranen v1
delay(tone_delay);
// DEBUG
//Serial.println(tone_delay);
Serial.println(tone_freq);
}
Loading…
Cancel
Save