Make A Whack-A-Mole Game!

  Рет қаралды 13,158

DIG at SMU

DIG at SMU

Күн бұрын

Пікірлер: 20
@АлександрЗахаров-э1ы
@АлександрЗахаров-э1ы 3 жыл бұрын
Very good, thanks
@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!
@fernandovazquez5637
@fernandovazquez5637 4 жыл бұрын
GREAT TUTORIAL!
@ntroncone
@ntroncone 2 жыл бұрын
nice explanation
@nikelvegasantrax2135
@nikelvegasantrax2135 8 ай бұрын
MASTER
@Alirezahez
@Alirezahez 3 жыл бұрын
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 4 жыл бұрын
How can you add more buttons and les to the program? For example 10 leds en buttons
@Pieter-Jan
@Pieter-Jan 4 жыл бұрын
I have no idea 😂
@digatsmu6667
@digatsmu6667 4 жыл бұрын
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
@vibhormittal1309
@vibhormittal1309 4 жыл бұрын
code please
@digatsmu6667
@digatsmu6667 4 жыл бұрын
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 4 жыл бұрын
@@digatsmu6667 thanks
@rahmanshazzad3838
@rahmanshazzad3838 Жыл бұрын
It das not need code
Arduino Uno Gets Its BIGGEST Upgrade In 12 Years
11:49
Electronoobs
Рет қаралды 75 М.
Building a DIY Simon game using an ARDUINO UNO?
16:10
Print 'N Play
Рет қаралды 16 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
I Made Chess 2.0
14:32
From Scratch
Рет қаралды 1,5 МЛН
Hacking a weird TV censoring device
20:59
Ben Eater
Рет қаралды 3,3 МЛН
How To Make a DIY LED Arcade Game Using Arduino (Makershala)
7:42
how to make robot eye moving using sound at your home
8:40
ROBOTICS KANTI
Рет қаралды 11 МЛН
Evolving AIs - More Complex Environment
22:24
Pezzza's Work
Рет қаралды 158 М.
Easy Interactive Paper Circuit for Kids! (DIY template)
11:14
Volt, Paper, Scissors!
Рет қаралды 11 М.
Mouse Cursor History (and why I made my own)
15:09
Posy
Рет қаралды 2,7 МЛН
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН