Jeu memory (samon say)

Jeu memory (samon say)

thingiverse

Conception of a Memory Game with Arduino Nano. Code of the game with a 50-cycle counter: int data_pin = 3; int latch_pin = 2; int clock_pin = 4; int speaker = 5; int button1 = 6; int button2 = 7; int button3 = 8; int button4 = 9; int led1 = 10; int led2 = 11; int led3 = 12; int led4 = 13; int sound[]={135,440,492,932}; int pause = 400; int enter_pause = 20; int lesspause = 10; int lives = 3; int number[]={192,249,164,176,153,146,130,248,128,144,64,121,36,48,25,18,2,120,0,16}; int melody[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; int led[]={10,11,12,13}; int level = 0; int melodybox = 0; int buttonState1 = 0; int buttonState2 = 0; int buttonState3 = 0; int buttonState4 = 0; boolean stopp = true; boolean allowbuttonpress = false; void setup() { Serial.begin(9600); pinMode(data_pin, OUTPUT); //Data pinMode(latch_pin, OUTPUT); //Latch pinMode(clock_pin, OUTPUT); //Clock pinMode(led1,OUTPUT); pinMode(led2,OUTPUT); pinMode(led3,OUTPUT); pinMode(led4,OUTPUT); } void loop() { if (stopp == true) { tone(speaker,sound[0]); delay(pause); noTone(speaker); delay(pause); stopp = false; } if (allowbuttonpress == true) { for(int i=0;i<4;i++){ if (digitalRead(button1)==HIGH) {melodybox=i;checkifcorrect(i);} else if (digitalRead(button2)==HIGH){melodybox=i;checkifcorrect(i);} else if (digitalRead(button3)==HIGH){melodybox=i;checkifcorrect(i);} else if (digitalRead(button4)==HIGH){melodybox=i;checkifcorrect(i);} } } } void checkifcorrect(int lednumber){ if (lednumber == melody[melodybox]){ toneandled(lednumber,pause,enter_pause); if(melodybox==level){sequencecorrect();} melodybox++; allowbuttonpress = true; } else{sequencefalse();} } void sequencecorrect(){ tone(speaker,475); delay(150); noTone(speaker); tone(speaker,475); delay(150); noTone(speaker); level++; writelevel(); pause = pause - lesspause; delay(1000); stopp=true; } void sequencefalse(){ lives=lives-1; for (int i=1;i<4-lives;i++){ tone(speaker,475); delay(150); noTone(speaker); tone(speaker,130); delay(650); noTone(speaker); delay(50); } delay(1000); if(lives==0){ level=0; lives=3; newrandomnumbers(); writelevel(); pause = 400; stopp=true;} } void writelevel(){ digitalWrite(latch_pin, LOW); shiftOut(data_pin, clock_pin, MSBFIRST,number[level]); digitalWrite(latch_pin, HIGH); delay (1000); } void newrandomnumbers(){ randomSeed(analogRead(0)); for(int i=0;i<20;i++){ melody[i]=random(0,4); } }

Download Model from thingiverse

With this file you will be able to print Jeu memory (samon say) with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on Jeu memory (samon say).