Created
July 25, 2014 06:22
-
-
Save campaul/14c56e1b7791bb13e18f to your computer and use it in GitHub Desktop.
Blind attempt at controlling the frequency of a 555 timer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int pin = 0; // The pin we will read the audio signal from | |
volatile int last = 0; // The time of the last sample | |
volatile int expected = 2272; // Roughly 440Hz | |
volatile int data = 0; // The direction to change the digi-pot | |
void setup() { | |
pinMode(pin, INPUT); | |
last = micros(); | |
attachInterrupt(0, adjust, FALLING); | |
} | |
void loop() { | |
// TODO: On midi input change the expected time | |
} | |
void adjust() { | |
int elapsed = micros() - last; | |
last += elapsed; | |
if (elapsed > expected) { | |
data = 1; | |
} else { | |
data = 0; | |
} | |
// TODO: Clock the digi-pot | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment