Flute.cpp

From IPRE Wiki
Jump to: navigation, search
#include <Myro.h>

// Define the 8 notes on the flute
int notes[] = {440,494,554,588,659,740,831,880};

const int THREASHOLD = 2000;

int main(){
    connect();
    std::vector<int> lights;
    int note;
    while (timeRemaining(60)){
        lights = robot.getLights();
        note = 0;
        if ( lights[0] > THREASHOLD )
            note += 1;
        if ( lights[1] > THREASHOLD )
            note += 2;
        if ( lights[2] > THREASHOLD )
            note += 4;
        // Have the scribbler play the note
        robot.beep(0.2, notes[note]);
    }
    disconnect();
}