author

Komalpreet

Inbox View Profile
3Instructables449Views3Comments

Tell us about yourself!

  • Simon Says Game; Arduino

    yes of course!! Hope this helps!!!const int RED = 10, BLUE = 11, YELLOW = 12, GREEN = 13;const int RED_IN = A3, BLUE_IN = A2, YELLOW_IN = A1, GREEN_IN = A0;const int SPEAKER = 3;int sequence[100]; int correct = 0; int button_pressed[100];void setup(){ pinMode(RED, OUTPUT); pinMode(BLUE, OUTPUT); pinMode(YELLOW, OUTPUT); pinMode(GREEN, OUTPUT); pinMode(SPEAKER, OUTPUT); digitalWrite(RED, LOW); digitalWrite(BLUE, LOW); digitalWrite(YELLOW, LOW); digitalWrite(GREEN, LOW); for(int siren_start = 0; siren_start < 5 ; siren_start++){ tone(SPEAKER, 1047); delay(100); noTone(SPEAKER); delay(200); } delay(1000); randomSeed(analogRead(0)); }void loop(){ for(int current = 0; current < 100; current++){ sequence[current] = random(4); PLAY(current); LISTEN…

    see more »

    yes of course!! Hope this helps!!!const int RED = 10, BLUE = 11, YELLOW = 12, GREEN = 13;const int RED_IN = A3, BLUE_IN = A2, YELLOW_IN = A1, GREEN_IN = A0;const int SPEAKER = 3;int sequence[100]; int correct = 0; int button_pressed[100];void setup(){ pinMode(RED, OUTPUT); pinMode(BLUE, OUTPUT); pinMode(YELLOW, OUTPUT); pinMode(GREEN, OUTPUT); pinMode(SPEAKER, OUTPUT); digitalWrite(RED, LOW); digitalWrite(BLUE, LOW); digitalWrite(YELLOW, LOW); digitalWrite(GREEN, LOW); for(int siren_start = 0; siren_start < 5 ; siren_start++){ tone(SPEAKER, 1047); delay(100); noTone(SPEAKER); delay(200); } delay(1000); randomSeed(analogRead(0)); }void loop(){ for(int current = 0; current < 100; current++){ sequence[current] = random(4); PLAY(current); LISTEN(current); if(correct == 1) { analogWrite(RED_IN,1023); analogWrite(BLUE_IN,1023); analogWrite(YELLOW_IN,1023); analogWrite(GREEN_IN,1023); tone(SPEAKER,523); delay(250); tone(SPEAKER,1047); delay(250); tone(SPEAKER,2093); delay(250); noTone(SPEAKER); analogWrite(RED_IN,0); analogWrite(BLUE_IN,0); analogWrite(YELLOW_IN,0); analogWrite(GREEN_IN,0); delay(500); } if(correct == 0) break; }}void PLAY(int current_stage){ for(int i = 0; i <= current_stage; i++){ switch(sequence[i]){ case 0: pinMode(RED_IN, OUTPUT); analogWrite(RED_IN,1023); tone(SPEAKER,294); delay(500); analogWrite(RED_IN,0); noTone(SPEAKER); delay(500); break; case 1: pinMode(BLUE_IN, OUTPUT); analogWrite(BLUE_IN,1023); tone(SPEAKER,440); delay(500); analogWrite(BLUE_IN,0); noTone(SPEAKER); delay(500); break; case 2: pinMode(YELLOW_IN, OUTPUT); analogWrite(YELLOW_IN,1023); tone(SPEAKER,587); delay(500); analogWrite(YELLOW_IN,0); noTone(SPEAKER); delay(500); break; case 3: pinMode(GREEN_IN, OUTPUT); analogWrite(GREEN_IN,1023); tone(SPEAKER,880); delay(500); analogWrite(GREEN_IN,0); noTone(SPEAKER); delay(500); break; } }}void LISTEN(int current_stage){ digitalWrite(RED, HIGH); digitalWrite(BLUE, HIGH); digitalWrite(YELLOW, HIGH); digitalWrite(GREEN, HIGH); pinMode(RED_IN, INPUT); pinMode(BLUE_IN, INPUT); pinMode(YELLOW_IN, INPUT); pinMode(GREEN_IN, INPUT); for (int i = 0; i <= current_stage; i++){ int valR = 0, valB = 0, valY = 0, valG = 0; while(valR < 400 && valB < 400 && valY < 400 && valG < 400){ valR = analogRead(RED_IN); valB = analogRead(BLUE_IN); valY = analogRead(YELLOW_IN); valG = analogRead(GREEN_IN); } delay(500); if(valR > 400) button_pressed[i] = 0; if(valB > 400) button_pressed[i] = 1; if(valY > 400) button_pressed[i] = 2; if(valG > 400) button_pressed[i] = 3; if (button_pressed[i] != sequence[i]){ pinMode(RED_IN, OUTPUT); pinMode(BLUE_IN, OUTPUT); pinMode(YELLOW_IN, OUTPUT); pinMode(GREEN_IN, OUTPUT); analogWrite(RED_IN,1023); analogWrite(BLUE_IN,1023); analogWrite(YELLOW_IN,1023); analogWrite(GREEN_IN,1023); tone(SPEAKER,262); delay(250); tone(SPEAKER,175); delay(250); tone(SPEAKER,123); delay(250); noTone(SPEAKER); analogWrite(RED_IN,0); analogWrite(BLUE_IN,0); analogWrite(YELLOW_IN,0); analogWrite(GREEN_IN,0); delay(500); correct = 0; break; } else correct = 1; }}

    Yes of course!! Hope this helps!!!const int RED = 10, BLUE = 11, YELLOW = 12, GREEN = 13;const int RED_IN = A3, BLUE_IN = A2, YELLOW_IN = A1, GREEN_IN = A0;const int SPEAKER = 3;int sequence[100];int correct = 0;int button_pressed[100];void setup(){pinMode(RED, OUTPUT);pinMode(BLUE, OUTPUT);pinMode(YELLOW, OUTPUT);pinMode(GREEN, OUTPUT);pinMode(SPEAKER, OUTPUT);digitalWrite(RED, LOW);digitalWrite(BLUE, LOW);digitalWrite(YELLOW, LOW);digitalWrite(GREEN, LOW);for(int siren_start = 0; siren_start < 5 ; siren_start++){tone(SPEAKER, 1047);delay(100);noTone(SPEAKER);delay(200);}delay(1000);randomSeed(analogRead(0));}void loop(){for(int current = 0; current < 100; current++){sequence[current] = random(4);PLAY(current);LISTEN(current);if(correct == 1) {analogWrite(RED_IN,1023);analogWrite(B…

    see more »

    Yes of course!! Hope this helps!!!const int RED = 10, BLUE = 11, YELLOW = 12, GREEN = 13;const int RED_IN = A3, BLUE_IN = A2, YELLOW_IN = A1, GREEN_IN = A0;const int SPEAKER = 3;int sequence[100];int correct = 0;int button_pressed[100];void setup(){pinMode(RED, OUTPUT);pinMode(BLUE, OUTPUT);pinMode(YELLOW, OUTPUT);pinMode(GREEN, OUTPUT);pinMode(SPEAKER, OUTPUT);digitalWrite(RED, LOW);digitalWrite(BLUE, LOW);digitalWrite(YELLOW, LOW);digitalWrite(GREEN, LOW);for(int siren_start = 0; siren_start < 5 ; siren_start++){tone(SPEAKER, 1047);delay(100);noTone(SPEAKER);delay(200);}delay(1000);randomSeed(analogRead(0));}void loop(){for(int current = 0; current < 100; current++){sequence[current] = random(4);PLAY(current);LISTEN(current);if(correct == 1) {analogWrite(RED_IN,1023);analogWrite(BLUE_IN,1023);analogWrite(YELLOW_IN,1023);analogWrite(GREEN_IN,1023);tone(SPEAKER,523);delay(250);tone(SPEAKER,1047);delay(250);tone(SPEAKER,2093);delay(250);noTone(SPEAKER);analogWrite(RED_IN,0);analogWrite(BLUE_IN,0);analogWrite(YELLOW_IN,0);analogWrite(GREEN_IN,0);delay(500);}if(correct == 0) break;}}void PLAY(int current_stage){for(int i = 0; i <= current_stage; i++){switch(sequence[i]){case 0:pinMode(RED_IN, OUTPUT);analogWrite(RED_IN,1023);tone(SPEAKER,294);delay(500);analogWrite(RED_IN,0);noTone(SPEAKER);delay(500);break;case 1:pinMode(BLUE_IN, OUTPUT);analogWrite(BLUE_IN,1023);tone(SPEAKER,440);delay(500);analogWrite(BLUE_IN,0);noTone(SPEAKER);delay(500);break;case 2:pinMode(YELLOW_IN, OUTPUT);analogWrite(YELLOW_IN,1023);tone(SPEAKER,587);delay(500);analogWrite(YELLOW_IN,0);noTone(SPEAKER);delay(500);break;case 3:pinMode(GREEN_IN, OUTPUT);analogWrite(GREEN_IN,1023);tone(SPEAKER,880);delay(500);analogWrite(GREEN_IN,0);noTone(SPEAKER);delay(500);break;}}}void LISTEN(int current_stage){digitalWrite(RED, HIGH);digitalWrite(BLUE, HIGH);digitalWrite(YELLOW, HIGH);digitalWrite(GREEN, HIGH);pinMode(RED_IN, INPUT);pinMode(BLUE_IN, INPUT);pinMode(YELLOW_IN, INPUT);pinMode(GREEN_IN, INPUT);for (int i = 0; i <= current_stage; i++){int valR = 0, valB = 0, valY = 0, valG = 0;while(valR < 400 && valB < 400 && valY < 400 && valG < 400){valR = analogRead(RED_IN);valB = analogRead(BLUE_IN);valY = analogRead(YELLOW_IN);valG = analogRead(GREEN_IN);}delay(500);if(valR > 400) button_pressed[i] = 0;if(valB > 400) button_pressed[i] = 1;if(valY > 400) button_pressed[i] = 2;if(valG > 400) button_pressed[i] = 3;if (button_pressed[i] != sequence[i]){pinMode(RED_IN, OUTPUT);pinMode(BLUE_IN, OUTPUT);pinMode(YELLOW_IN, OUTPUT);pinMode(GREEN_IN, OUTPUT);analogWrite(RED_IN,1023);analogWrite(BLUE_IN,1023);analogWrite(YELLOW_IN,1023);analogWrite(GREEN_IN,1023);tone(SPEAKER,262);delay(250);tone(SPEAKER,175);delay(250);tone(SPEAKER,123);delay(250);noTone(SPEAKER);analogWrite(RED_IN,0);analogWrite(BLUE_IN,0);analogWrite(YELLOW_IN,0);analogWrite(GREEN_IN,0);delay(500);correct = 0;break;}else correct = 1;}}

    View Instructable »
  • Komalpreet's instructable Digital Dice With a Twist's weekly stats:
    • Digital Dice With a Twist
      53 views
      2 favorites
      1 comments
  • Komalpreet's instructable Simon Says Game; Arduino 's weekly stats:
    • Simon Says Game; Arduino
      34 views
      0 favorites
      0 comments
    • Arduino Light Intensity Lamp; QUICK AND EASY
      46 views
      0 favorites
      1 comments