Skip to content

Instantly share code, notes, and snippets.

@jononon
Created December 18, 2014 01:33
Show Gist options
  • Save jononon/47c3a25ee47f277b81df to your computer and use it in GitHub Desktop.
Save jononon/47c3a25ee47f277b81df to your computer and use it in GitHub Desktop.
Door Guard for Robotics
#pragma config(Sensor, S1, Door, sensorEV3_Ultrasonic)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main() {
setLEDColor(ledOrangePulse);
wait1Msec(3000);
int threshold = SensorValue[Door]-10;
while(true) {
setLEDColor(ledGreenPulse);
if(SensorValue[Door]<threshold) {
setLEDColor(ledRedFlash);
PlayTone( 880, 7); wait1Msec( 75); // Note(D, Duration(32th))
PlayTone( 933, 7); wait1Msec( 75); // Note(D#, Duration(32th))
PlayTone( 880, 7); wait1Msec( 75); // Note(D, Duration(32th))
PlayTone( 933, 7); wait1Msec( 75); // Note(D#, Duration(32th))
PlayTone( 880, 7); wait1Msec( 75); // Note(D, Duration(32th))
PlayTone( 933, 7); wait1Msec( 75); // Note(D#, Duration(32th))
PlayTone( 880, 7); wait1Msec( 75); // Note(D, Duration(32th))
PlayTone( 933, 7); wait1Msec( 75); // Note(D#, Duration(32th))
PlayTone( 880, 7); wait1Msec( 75); // Note(D, Duration(32th))
PlayTone( 880, 7); wait1Msec( 75); // Note(D, Duration(32th))
PlayTone( 933, 7); wait1Msec( 75); // Note(D#, Duration(32th))
PlayTone( 988, 7); wait1Msec( 75); // Note(E, Duration(32th))
PlayTone( 1047, 7); wait1Msec( 75); // Note(F, Duration(32th))
PlayTone( 1109, 7); wait1Msec( 75); // Note(F#, Duration(32th))
PlayTone( 1175, 7); wait1Msec( 75); // Note(G, Duration(32th))
PlayTone( 1175, 14); wait1Msec( 150); // Note(G, Duration(16th))
PlayTone( 0, 27); wait1Msec( 300); // Note(Rest, Duration(Eighth))
PlayTone( 1175, 14); wait1Msec( 150); // Note(G, Duration(16th))
PlayTone( 0, 27); wait1Msec( 300); // Note(Rest, Duration(Eighth))
PlayTone( 1398, 14); wait1Msec( 150); // Note(A#, Duration(16th))
PlayTone( 0, 14); wait1Msec( 150); // Note(Rest, Duration(16th))
PlayTone( 784, 14); wait1Msec( 150); // Note(C, Duration(16th))
PlayTone( 0, 14); wait1Msec( 150); // Note(Rest, Duration(16th))
PlayTone( 1175, 14); wait1Msec( 150); // Note(G, Duration(16th))
PlayTone( 0, 27); wait1Msec( 300); // Note(Rest, Duration(Eighth))
PlayTone( 1175, 14); wait1Msec( 150); // Note(G, Duration(16th))
PlayTone( 0, 27); wait1Msec( 300); // Note(Rest, Duration(Eighth))
PlayTone( 1047, 14); wait1Msec( 150); // Note(F, Duration(16th))
PlayTone( 0, 14); wait1Msec( 150); // Note(Rest, Duration(16th))
PlayTone( 1109, 14); wait1Msec( 150); // Note(F#, Duration(16th))
PlayTone( 0, 14); wait1Msec( 150); // Note(Rest, Duration(16th))
PlayTone( 1175, 14); wait1Msec( 150); // Note(G, Duration(16th))
PlayTone( 0, 27); wait1Msec( 300); // Note(Rest, Duration(Eighth))
PlayTone( 1175, 14); wait1Msec( 150); // Note(G, Duration(16th))
PlayTone( 0, 27); wait1Msec( 300); // Note(Rest, Duration(Eighth))
PlayTone( 1398, 14); wait1Msec( 150); // Note(A#, Duration(16th))
PlayTone( 0, 14); wait1Msec( 150); // Note(Rest, Duration(16th))
PlayTone( 784, 14); wait1Msec( 150); // Note(C, Duration(16th))
PlayTone( 0, 14); wait1Msec( 150); // Note(Rest, Duration(16th))
PlayTone( 1175, 14); wait1Msec( 150); // Note(G, Duration(16th))
PlayTone( 0, 27); wait1Msec( 300); // Note(Rest, Duration(Eighth))
PlayTone( 1175, 14); wait1Msec( 150); // Note(G, Duration(16th))
PlayTone( 0, 27); wait1Msec( 300); // Note(Rest, Duration(Eighth))
PlayTone( 1047, 14); wait1Msec( 150); // Note(F, Duration(16th))
PlayTone( 0, 14); wait1Msec( 150); // Note(Rest, Duration(16th))
PlayTone( 1109, 14); wait1Msec( 150); // Note(F#, Duration(16th))
PlayTone( 0, 14); wait1Msec( 150); // Note(Rest, Duration(16th))
PlayTone( 1398, 14); wait1Msec( 150); // Note(A#, Duration(16th))
PlayTone( 1175, 14); wait1Msec( 150); // Note(G, Duration(16th))
PlayTone( 880, 108); wait1Msec(1200); // Note(D, Duration(Half))
PlayTone( 0, 7); wait1Msec( 75); // Note(Rest, Duration(32th))
PlayTone( 1398, 14); wait1Msec( 150); // Note(A#, Duration(16th))
PlayTone( 1175, 14); wait1Msec( 150); // Note(G, Duration(16th))
PlayTone( 831, 108); wait1Msec(1200); // Note(C#, Duration(Half))
PlayTone( 0, 7); wait1Msec( 75); // Note(Rest, Duration(32th))
PlayTone( 1398, 14); wait1Msec( 150); // Note(A#, Duration(16th))
PlayTone( 1175, 14); wait1Msec( 150); // Note(G, Duration(16th))
PlayTone( 784, 108); wait1Msec(1200); // Note(C, Duration(Half))
PlayTone( 0, 14); wait1Msec( 150); // Note(Rest, Duration(16th))
PlayTone( 932, 14); wait1Msec( 150); // Note(A#5, Duration(16th))
PlayTone( 784, 14); wait1Msec( 150); // Note(C, Duration(16th))
while(SensorValue[Door]<threshold) { wait1Msec(1000); }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment