Тёмный

Make A Whack-A-Mole Game! 

DIG at SMU
Подписаться 231
Просмотров 12 тыс.
50% 1

Опубликовано:

 

27 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 20   
@alexhudita2548
@alexhudita2548 3 года назад
I did the montage and use the code, but its turning on just the second led and none of the pushbuttons are working. An advice ?
@digatsmu6667
@digatsmu6667 3 года назад
Hi Alex! I'm sorry you're having that problem! Are you using TinkerCAD or did you make it in person? If it was on TinkerCAD, could you reply with the link? IN PERSON: If you made it in person and the code is compiling correctly and you followed the code from the video, there may be an error within your circuit wiring. I would try looking at your wiring in comparison to the original schematic (in the description box). If the wiring matches perfectly, the components may not be working properly. For an LED, I would use a resistor that is approximately 300 Ohms. For the grounding resistor, I believe you may need about 220-Ohm resistors, but you can use higher resistances to ground the pushbutton. An easy way to check if the components are the ones not working is by making a simple series circuit where you put the LED, a resistor, and a pushbutton connected to the power source within the Arduino Board. Below I linked an example of how to test your circuit: www.tinkercad.com/things/kJpmFD9xRgd-mighty-bigery/editel?sharecode=XjwjhFaxDQMreg_53MRyBF0yF-AhfUfQnA-jjseGCf4 Another common error when making the circuit in-person is that an LED can only be connected one way. The longer leg of an LED (the anode) should go to the numbered pins in the Arduino. The shorter leg of an LED (the cathode) should go to one of the GND pins. You can put a resistor either between the long leg and the numbered pin, or between the short leg and the GND pin. However, that would not explain the buttons not working, that may be a problem with the resistance that you use to ground them or something in the code being off. Look at the original TinkerCAD code in the description box and maybe compare line by line when you're looking at the for loop that controls the LEDs and the buttons. TINKERCAD: If you used TinkerCAD and you followed the tutorial, did you make it on a personal file or did you copy and tinker the original circuit found in the description box? I re-check the code that is linked to see if there's a mistake on our side and it seems to be working fine! If you use the link in the description box, it should work! If you did not use the link, I would try once again looking at the wiring, that's the most common error. If that seems to be correct, maybe re-check your code in sections. Specifically, the beginning of the for loop that controls what LEDs are randomly turned on. Try looking at the code linked in the description box, it should be very detailed with a lot of comments. Hopefully, this is helpful!
@АлександрЗахаров-э1ы
Very good, thanks
@ntroncone
@ntroncone 2 года назад
nice explanation
@fernandovazquez5637
@fernandovazquez5637 4 года назад
GREAT TUTORIAL!
@vibhormittal1309
@vibhormittal1309 3 года назад
code please
@digatsmu6667
@digatsmu6667 3 года назад
Hello! The code is in the description box! It should be "Link to TinkerCAD Original Design". You can download the code from there!
@vibhormittal1309
@vibhormittal1309 3 года назад
@@digatsmu6667 thanks
@rahmanshazzad3838
@rahmanshazzad3838 9 месяцев назад
It das not need code
@nikelvegasantrax2135
@nikelvegasantrax2135 5 месяцев назад
MASTER
@Alirezahez
@Alirezahez 2 года назад
Hi if I want to do the same thing but with arm assembly code, how would I do it? is there assembly code for it too so I can use it?
@digatsmu6667
@digatsmu6667 2 года назад
Hi there! Unfortunately, we don't have a code already made in ARM assembly code. Sorry!
@Pieter-Jan
@Pieter-Jan 3 года назад
How can you add more buttons and les to the program? For example 10 leds en buttons
@Pieter-Jan
@Pieter-Jan 3 года назад
I have no idea 😂
@digatsmu6667
@digatsmu6667 3 года назад
Hello Pieter! If you would like to add more buttons and LEDs to the program only using the digital pins (which are the top pins on the diagram), you would just add your LEDs and respective buttons to the remaining free pins. There is a loop that randomizes the LEDs that turn on, so do try to put all the LED pins together to make it easier to randomize. For example, put all your LEDs on pins 0-6 (which gives you 7 LEDs) and all your buttons from pins 7-13 (which gives you 7 buttons). Your loop that randomizes the LEDs (in line 35 of the original code) would therefore have to be from 0 to 7 (this would only randomize numbers up to 6). In total, you should be able to get 7 LEDs and 7 buttons on that way. If you want more than 7 LEDs and 7 buttons with one Arduino, you would have to use the analog pins (which are labeled "A0, A1, A2, ..." on the Arduino). I believe you can use the analog pins as digital using the same digitalRead and digitalWrite commands. However, you would have to call each pin "A#" instead of just # since the singular numbers are already used for the digital pins. This would mean you'd have to alter your codes to adapt to the fact that the pins are no longer only integers. So whenever you are declaring the "const int _______" variables, you won't be able to do that with the analog pins since it will give you an error for having an "A". Therefore, you would have to hard code the digitalRead/digitalWrite/pinMode commands for any LEDs and buttons wired at the analog pins. You may also come into a problem whenever you are randomizing which LED turns on (once again, line 35 in the original code that is linked) if you have LEDs on the analog side since it will no longer be a pin that is a number only, so you can't randomize inside of the digitalWrite. You would have to still randomize a number from 0 to 10 (if you wanted 10 LEDs and 10 buttons), but maybe use an if-else statement to label each pin with a number from 0-9 as needed. If you need any more information or clarification, leave a comment and we'll answer as soon as we can!
@Pieter-Jan
@Pieter-Jan 3 года назад
@@digatsmu6667 I tried making a program but i doesn't work. I have an Arduino Mega so I have like 50 pins. I want to make this program with 10 leds and 10 buttons but I can't. I hope you guys can help me.
@Pieter-Jan
@Pieter-Jan 3 года назад
@@digatsmu6667 /First, we will declare some integers to for the pin values const int redLED = 0; const int blueLED = 1; const int greenLED = 2; const int yellowLED = 3; const int ta = 4; const int bla = 5; const int boo = 6; const int redButton = 7; const int blueButton = 8; const int greenButton = 9; const int yellowButton = 10; const int tak = 11; const int blad = 12; const int boom = 13; //place where you declare the LEDs and buttons as input or output //connects them to Arduino so it knows how to manipulate void setup() { //Set LED pins as outputs (only displays light) pinMode(redLED, OUTPUT); pinMode(blueLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(yellowLED, OUTPUT); pinMode(ta, OUTPUT); pinMode(bla, OUTPUT); pinMode(boo, OUTPUT); //Set Buttons as inputs (controls if you whacked the "mole") pinMode(redButton, INPUT); pinMode(blueButton, INPUT); pinMode(greenButton, INPUT); pinMode(yellowButton, INPUT); pinMode(tak, INPUT); pinMode(blad, INPUT); pinMode(boom, INPUT); } void loop() { //Makes sure that the game ends after 30 lights are whacked for(int i = 0; i < 10; i++) { //Randomly turns on an LED digitalWrite(random(0, 7), HIGH); //Checks if any of the LEDs are on while(digitalRead(redLED) == HIGH || digitalRead(blueLED) == HIGH || digitalRead(greenLED) == HIGH ||digitalRead(yellowLED) == HIGH||digitalRead(ta) == HIGH||digitalRead(bla) == HIGH||digitalRead(boo) == HIGH) { //Functions that turns off the randomly lit LED if (digitalRead(redLED) == HIGH) { // Makes sure button is pressed if (digitalRead(redButton) == HIGH) { //Turns off LED digitalWrite(redLED, LOW); } } if (digitalRead(blueLED) == HIGH) { // Makes sure button is pressed if(digitalRead(blueButton) == HIGH) { //Turns off LED digitalWrite(blueLED, LOW); } } if (digitalRead(greenLED) == HIGH) { //Makes sure button is pressed if(digitalRead(greenButton) == HIGH) { //Turns off LED digitalWrite(greenLED, LOW); } } if (digitalRead(yellowLED) == HIGH) { // Makes sure button is pressed if(digitalRead(yellowButton) == HIGH) { //Turns off LED digitalWrite(yellowLED, LOW); } } if (digitalRead(ta) == HIGH) { // Makes sure button is pressed if(digitalRead(tak) == HIGH) { //Turns off LED digitalWrite(ta, LOW); } } if (digitalRead(bla) == HIGH) { // Makes sure button is pressed if(digitalRead(blad) == HIGH) { //Turns off LED digitalWrite(bla, LOW); } } if (digitalRead(boo) == HIGH) { // Makes sure button is pressed if(digitalRead(boom) == HIGH) { //Turns off LED digitalWrite(boo, LOW); } } delay(100); } } //Shows the end of the game //First, we will declare some integers to for the pin values const int redLED = 0; const int blueLED = 1; const int greenLED = 2; const int yellowLED = 3; const int ta = 4; const int bla = 5; const int boo = 6; const int redButton = 7; const int blueButton = 8; const int greenButton = 9; const int yellowButton = 10; const int tak = 11; const int blad = 12; const int boom = 13; //place where you declare the LEDs and buttons as input or output //connects them to Arduino so it knows how to manipulate void setup() { //Set LED pins as outputs (only displays light) pinMode(redLED, OUTPUT); pinMode(blueLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(yellowLED, OUTPUT); pinMode(ta, OUTPUT); pinMode(bla, OUTPUT); pinMode(boo, OUTPUT); //Set Buttons as inputs (controls if you whacked the "mole") pinMode(redButton, INPUT); pinMode(blueButton, INPUT); pinMode(greenButton, INPUT); pinMode(yellowButton, INPUT); pinMode(tak, INPUT); pinMode(blad, INPUT); pinMode(boom, INPUT); } void loop() { //Makes sure that the game ends after 30 lights are whacked for(int i = 0; i < 10; i++) { //Randomly turns on an LED digitalWrite(random(0, 7), HIGH); //Checks if any of the LEDs are on while(digitalRead(redLED) == HIGH || digitalRead(blueLED) == HIGH || digitalRead(greenLED) == HIGH ||digitalRead(yellowLED) == HIGH||digitalRead(ta) == HIGH||digitalRead(bla) == HIGH||digitalRead(boo) == HIGH) { //Functions that turns off the randomly lit LED if (digitalRead(redLED) == HIGH) { // Makes sure button is pressed if (digitalRead(redButton) == HIGH) { //Turns off LED digitalWrite(redLED, LOW); } } if (digitalRead(blueLED) == HIGH) { // Makes sure button is pressed if(digitalRead(blueButton) == HIGH) { //Turns off LED digitalWrite(blueLED, LOW); } } if (digitalRead(greenLED) == HIGH) { //Makes sure button is pressed if(digitalRead(greenButton) == HIGH) { //Turns off LED digitalWrite(greenLED, LOW); } } if (digitalRead(yellowLED) == HIGH) { // Makes sure button is pressed if(digitalRead(yellowButton) == HIGH) { //Turns off LED digitalWrite(yellowLED, LOW); } } if (digitalRead(ta) == HIGH) { // Makes sure button is pressed if(digitalRead(tak) == HIGH) { //Turns off LED digitalWrite(ta, LOW); } } if (digitalRead(bla) == HIGH) { // Makes sure button is pressed if(digitalRead(blad) == HIGH) { //Turns off LED digitalWrite(bla, LOW); } } if (digitalRead(boo) == HIGH) { // Makes sure button is pressed if(digitalRead(boom) == HIGH) { //Turns off LED digitalWrite(boo, LOW); } } delay(100); } //Shows the end of the game for (int i = 0; i < 3; i++) { digitalWrite(redLED, HIGH); digitalWrite(blueLED, HIGH); digitalWrite(greenLED, HIGH); digitalWrite(yellowLED, HIGH); digitalWrite(ta, HIGH); digitalWrite(bla, HIGH); digitalWrite(boo, HIGH); delay(250); // Wait for 250 millisecond(s) digitalWrite(redLED, LOW); digitalWrite(blueLED, LOW); digitalWrite(greenLED, LOW); digitalWrite(yellowLED, LOW); digitalWrite(ta, LOW); digitalWrite(bla, LOW); digitalWrite(boo, LOW); delay(250); // Wait for 250 millisecond(s) } } { digitalWrite(redLED, HIGH); digitalWrite(blueLED, HIGH); digitalWrite(greenLED, HIGH); digitalWrite(yellowLED, HIGH); digitalWrite(ta, HIGH); digitalWrite(bla, HIGH); digitalWrite(boo, HIGH); delay(250); // Wait for 250 millisecond(s) digitalWrite(redLED, LOW); digitalWrite(blueLED, LOW); digitalWrite(greenLED, LOW); digitalWrite(yellowLED, LOW); digitalWrite(ta, LOW); digitalWrite(bla, LOW); digitalWrite(boo, LOW); delay(250); // Wait for 250 millisecond(s) } }
@digatsmu6667
@digatsmu6667 3 года назад
@@Pieter-Jan Hi Pieter! Give me some time to look at your code to see if there is a mistake or something of the sort! I'll get back to you when I figure it out! - Dalia
Далее
Looming Workshop
14:39
Просмотров 203
Making A Whack A Mole Game In Scratch | Part 1
12:18
"Когти льва" Анатолий МАЛЕЦ
53:01
Avaz Oxun - Yangisidan bor
14:29
Просмотров 361 тыс.
Brilliant Budget-Friendly Tips for Car Painting!
00:28
Новая BMW 5 провал за 10 млн! ИЛИ?..
32:07
Forget About Raspberry Pi! Use Your Old Phone Instead.
9:09
Making a Mini Whack A Mole Game
10:36
Просмотров 13 тыс.
Speed On | An Arduino Game Project
2:50
Просмотров 8 тыс.
Can Dangerous Saw Blades Cut Wood?
25:34
Просмотров 2,6 тыс.
I Made The Ultimate Cheating Device
9:39
Просмотров 1 млн
The world's worst video card?
32:47
Просмотров 6 млн
Whack A Mole with Arduino
1:12
Просмотров 6 тыс.
Full video - Data recovery from a dead MicroSD card
16:01
"Когти льва" Анатолий МАЛЕЦ
53:01