Created
November 5, 2018 22:45
-
-
Save NimaBoscarino/c136dbe291c48663f1e7be89bc0fed39 to your computer and use it in GitHub Desktop.
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
#include <LittleRobotFriends.h> | |
boolean soundOn = false; | |
int freq = 100; | |
void myTapHandler(LRFEvent event) { | |
soundOn = !soundOn; | |
} | |
void setup() | |
{ | |
lrf.setup(); | |
lrf.disableEventExpressions(); | |
lrf.setBoredomTimer(0); | |
lrf.setEventHandler(LRFEvent_Tap, &myTapHandler); | |
} | |
void loop() | |
{ | |
lrf.loop(); | |
if (soundOn) { | |
if (lrf.motion.readX() > 5) { | |
freq++; | |
} | |
else if (lrf.motion.readX() < - 5) { | |
freq--; | |
} | |
lrf.speech.setFrequency(freq); | |
} | |
else { | |
lrf.speech.setFrequency(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment