Created
August 9, 2018 20:07
-
-
Save NimaBoscarino/042fb625b5c9117778d50f9e254ea17c 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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment