You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.2 KiB
Arduino

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