Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int motion_1 = 2;
- int light_1 = 13;
- //int note[] = {31,33,35,37,39,41,44,46,49,52,55,58,62,65,69,73,78,82,87,93,98,104,110,117,123,131,139,147,156,165,175,185,196,208,220,233,247,262,277,294,311,330,349,370,392,415,440,466,494,523,554,587,622,659,698,740,784,831,880,932,988,1047,1109,1175,1245,1319,1397,1480,1568,1661,1760,1865,1976,2093,2217,2349,2489,2637,2794,2960,3136,3322,3520,3729,3951,4186,4435,4699,4978};
- int note[] = {103, 839, 462, 336, 257, 269, 228, 929, 757, 499, 159, 988, 249, 671, 523, 165, 911, 470, 994, 883, 294, 290, 946, 337, 121, 526, 414, 250, 270, 854, 125, 354, 134, 653, 585, 295, 227, 406, 261, 919, 966, 481, 242, 36, 524, 356, 440, 37, 42, 841};
- void setup() {
- pinMode (motion_1, INPUT);
- //pinMode (light_1, OUTPUT);
- pinMode(9, OUTPUT);
- pinMode(12, OUTPUT);
- }
- void loop () {
- int sensor_1 = digitalRead(motion_1);
- if (sensor_1 == HIGH) {
- for(int x=0; x < 89; x++) {
- tone(8, note[x], 70);
- delay(70);
- }
- digitalWrite(12, LOW);
- digitalWrite(9, HIGH);
- delay(500);
- digitalWrite(9, LOW);
- delay(500);
- digitalWrite(9, HIGH);
- delay(500);
- digitalWrite(9, LOW);
- delay(500);
- digitalWrite(9, HIGH);
- delay(500);
- digitalWrite(9, LOW);
- delay(500);
- } else {
- digitalWrite(9, LOW);
- digitalWrite(12, HIGH);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment