ice-king v1

master
ugrnm 5 years ago
parent 2cc127c40c
commit 4acff9fa76

@ -1,5 +1,16 @@
/* /*
ICE KING
I C E K I N G
/ | | \
/ | ߇ | \
POT 1: Amount of Penguins
POT 2: Cryokinesis Strength
POT 3: Gunter
CHANGELOG:
20190922 - v1 !!!
*/ */
#define POT1 (0) #define POT1 (0)
@ -11,11 +22,12 @@ int t;
int u; int u;
int tone_delay; int tone_delay;
int tone_freq; int tone_freq;
int bitshift;
void void
setup() setup()
{ {
Serial.begin(9600); // DEBUG //Serial.begin(9600); // DEBUG
pinMode(SPEAKER, OUTPUT); pinMode(SPEAKER, OUTPUT);
} }
@ -23,21 +35,26 @@ void
loop() loop()
{ {
// 1CE C0DE // 1CE C0DE
// POT1 controls the final amount of right shift (0-31)
//bitshift = analogRead(POT3) // 32; meergranen v2
bitshift = (1023 - analogRead(POT3)) / 32; // meergranen v1
t++; t++;
u = (t*t/256)&(t>>((t/1024)%16))^t%64*(0x1CEC0DE>>(t>>9&30)&t%32)*t>>18; u = (t*t/256)&(t>>((t/1024)%16))^t%64*(0x1CEC0DE>>(t>>9&30)&t%32)*t>>bitshift;
// Use bytebeat u value as tone frequency // Use bytebeat u value as tone frequency modulated by POT2
// tone(pin, frequency) is provided by Arduino lib // Note: tone(pin, frequency) is provided by Arduino lib
tone_freq = u * (((1023 - analogRead(POT2)) / 10) + 1); //tone_freq = u * ((analogRead(POT2) / 32) + 1); // meergranen v2
tone_freq = u * (((1023 - analogRead(POT2)) / 32) + 1); // meergranen v1
tone(SPEAKER, tone_freq); tone(SPEAKER, tone_freq);
// Use pot 1 to set the tone duration (0-31) // Use POT1 to set the tone duration (63-0)
//tone_delay = analogRead(POT1) / 32; // meergranen v2 //tone_delay = (1023 - analogRead(POT1)) / 16; // meergranen v2
tone_delay = (1023 - analogRead(POT1)) / 32; // meergranen v1 tone_delay = analogRead(POT1) / 16; // meergranen v1
delay(tone_delay); delay(tone_delay);
// DEBUG // DEBUG
//Serial.println(tone_delay); //Serial.println(tone_delay);
Serial.println(tone_freq); //Serial.println(tone_freq);
//Serial.println(t);
} }

Loading…
Cancel
Save