Skip to content

Instantly share code, notes, and snippets.

@tgk
Created October 23, 2016 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgk/cdcc5e3d05e08c52dfc2920a95811317 to your computer and use it in GitHub Desktop.
Save tgk/cdcc5e3d05e08c52dfc2920a95811317 to your computer and use it in GitHub Desktop.
Fart machine for Rosalina - source
void fart(int pitch) {
int duration = random(300, 1000);
tone(8, pitch, duration);
delay(duration);
noTone(8);
}
int fartPitch() {
return map(analogRead(2), 0, 1023, 60, 110);
}
void setup() {
pinMode(4, INPUT);
pinMode(13, OUTPUT);
}
int buttonState = 0;
void loop() {
buttonState = digitalRead(4);
if(buttonState == HIGH) {
fart(fartPitch());
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
}
delay(50);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment