#include <IRremote.h>
// CONFIG: MODIFY VALUES TO FIT PLAY STYLE
const int maxAmmo = 5; // maximum ammunition count (max is 9)
const int shootCooldown = 500; // interval between each shot (in ms)
const int reloadTime = 1600; // time it takes to reload the gun (in ms)
const int resetTime = 500; // time the reset button has to be pressed to reset (in ms)
byte triggerPin = 2;
byte reloadPin = 3;
byte resetPin = 13;
byte irPin = 9;
byte hitLedPin = 6;
byte buzzerPin = 7;
byte pinsSegments[7] = {A0, A1, A2, A3, A4, A5, 12};
//ir communication
IRsend irsend; // setup IR transmitter
// arrays of digits for 7 segment display
const bool digits[10][7] = {
{0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 1, 1, 1, 1},
{0, 0, 1, 0, 0, 1, 0},
{0, 0, 0, 0, 1, 1, 0},
{1, 0, 0, 1, 1, 0, 0},
{0, 1, 0, 0, 1, 0, 0},
{0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 1},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0}
};
// reload animation on 7 segment display
const bool reloadAnimation[6][7] = {
{0, 1, 1, 1, 1, 1, 1},
{1, 0, 1, 1, 1, 1, 1},
{1, 1, 0, 1, 1, 1, 1},
{1, 1, 1, 0, 1, 1, 1},
{1, 1, 1, 1, 0, 1, 1},
{1, 1, 1, 1, 1, 0, 1}
};
const int animationLength = 6;
const int animationInterval = 100;
// shoot sound effect
const int shootSoundStartTone = 1000;
const int shootSoundEndTone = 700;
const int shootSoundInterval = 1;
//other variables
int ammoCount = maxAmmo;
unsigned long lastShot = shootCooldown*-1;
unsigned long startedReload = reloadTime*-1;
bool reloading = false;
unsigned long startedResetting = 0;
bool resetting = false;
unsigned long millisStartedTone = 0;
bool playingMelody = false;
int currentToneIdx = 0;
bool playingShootSound = false;
unsigned long millisStartedFrame = 0;
int currentFrameIdx = 0;
// reset function
void(* reset) (void) = 0;
// function to display digits on the 7 segment display
void displaySegments(bool segments[7]) {
for(byte seg=0; seg<7; seg+=1) {
digitalWrite(pinsSegments[seg], segments[seg]);
}
}
void setup()
{
// setup pins
pinMode(triggerPin, INPUT_PULLUP);
pinMode(reloadPin, INPUT_PULLUP);
pinMode(resetPin, INPUT_PULLUP);
pinMode(irPin, OUTPUT);
pinMode(hitLedPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
for(byte i=0; i<7; i+=1) {
pinMode(pinsSegments[i], OUTPUT);
}
// GAME SETUP
displaySegments(digits[ammoCount]); // display ammo count
// play startup sound effect
int startTones[] = { 196, 262, 330, 392 };
for(int i=0; i<4; i++)
{
tone(buzzerPin, startTones[i]);
delay(200);
}
noTone(buzzerPin);
}
void loop()
{
// display ammo count
if(!reloading) {
displaySegments(digits[ammoCount]);
}
// play sounds
if (playingMelody) {
if (currentMillis - millisStartedTone >= melodyInterval) { // we are playing a melody, check if we finished playing current tone
if(currentToneIdx+1 == melodyLength){ // we finished playing a tone, check if we finished the melody
// end of melody
noTone(buzzerPin);
playingMelody = false;
} else { // we haven't finished the melody
// play next tone
currentToneIdx++;
millisStartedTone = currentMillis;
tone(buzzerPin, hitMelody[currentToneIdx]);
}
}
} else if (playingShootSound) {
if (currentMillis - millisStartedTone >= shootSoundInterval) {
if(currentToneIdx <= shootSoundEndTone) {
// end of melody
noTone(buzzerPin);
playingShootSound = false;
} else {
// play next tone
currentToneIdx -= 1;
millisStartedTone = currentMillis;
tone(buzzerPin, currentToneIdx);
}
}
}
// play reload animation
if (reloading) {
if (currentMillis - millisStartedFrame >= animationInterval) { // we are playing reload animation, check if we finished playing current frame
// play next frame
currentFrameIdx++;
// cycle to start if reached end of animation
if (currentFrameIdx > animationLength-1) {
currentFrameIdx = 0;
}
millisStartedFrame = currentMillis;
displaySegments(reloadAnimation[currentFrameIdx]);
}
}
// input: reset
if (digitalRead(resetPin) == LOW) {
if(resetting) { // check if we were already holding the reset button
if(currentMillis - startedResetting >= resetTime) { // check if we held the reset button for enough time
reset();
}
} else { // start a new timer when we press it
startedResetting = currentMillis;
resetting = true;
}
} else {
resetting = false;
}
// input: shoot
if (digitalRead(triggerPin) == LOW && ammoCount > 0 && !reloading && currentMillis - lastShot >= shootCooldown)
{
// SHOOT
irsend.sendNEC(irSendHex, 32); // send IR
irrecv.enableIRIn(); // restart IR receiver
ammoCount--;
lastShot = currentMillis;
// SHOOT SFX
currentToneIdx = shootSoundStartTone;
millisStartedTone = currentMillis;
tone(buzzerPin, currentToneIdx);
if(playingMelody) {
playingMelody = false;
}
playingShootSound = true;
}
// input: reload
if (digitalRead(reloadPin) == LOW && ammoCount < maxAmmo && !reloading) {
reloading = true;
startedReload = currentMillis;
// RELOAD ANIMATION
currentFrameIdx = 0;
millisStartedFrame = currentMillis;
displaySegments(reloadAnimation[currentFrameIdx]);
}
// reload gun
if (reloading && currentMillis - startedReload >= reloadTime) {
ammoCount = maxAmmo;
reloading = false;
}
// GETTING SHOT SFX
currentToneIdx = 0;
millisStartedTone = currentMillis;
tone(buzzerPin, hitMelody[currentToneIdx]);
if(playingShootSound) {
playingShootSound = false;
}
playingMelody = true;
}
}
You will have to give a good description of the problems that you're experiencing.
First thing that I see. An unsigned long can not hold a negative number.
"Help identifying currentMillis"
You have copy/pasted an incomplete sketch or sketches. Missing are:
IRrecv irrecv
irSendHex
currentMillis
melodyInterval
melodyLength
hitMelody[]
The thing is I don't use receiver in my code, but still thanks
Then why did you include it?
Show a link to the original sketch(es).
Wdym by original sketch? Laser Tag Guns With Arduino
Here's the source I use for my IR gun's code and circuit.
My idea is to make this IR gun but only one, to shoot targets that receives IR from gun. My gun should not have health points.
What is your problem with currentMillis?
I used a code from other guy, but we have different idea, so I changed it a lot (e.g., he uses ir receiver, i don't use it because my idea is to make IR gun that shoots only, without laser tag). His code is working but mine not (btw even when I use his code, buzzer doesn't work for me). It shows this error Compilation error: 'currentMillis' was not declared in this scope
As I see, It's too early to say that the code doesn't work; it doesn't even compile yet.
Please show a compilation error message in full.
And what is your problem? You said that you "edited code a lot" - don't you know how to declare a variable?
I, theoretically know how to define a variable, but code is not mine, so I'm not sure how exactly I should define it
What kind of help do you expect from this forum?
Try it and show the code.
You should probably define currentMillis like the other guy did.
See post #3.
This requires a password to view the original sketch. You should upload the original "sketch" (program code) here. Your editing needs to be fixed.
[edit] Got it... here is the original sketch... and it compiles nicely. Now, to compare original to edited and make corrections...
#include <IRremote.h>
// CONFIG: MODIFY VALUES TO FIT PLAY STYLE
const int maxHealth = 10; // maximum health points
const int maxAmmo = 5; // maximum ammunition count (max is 9)
const int shootCooldown = 500; // interval between each shot (in ms)
const int reloadTime = 1600; // time it takes to reload the gun (in ms)
const int resetTime = 500; // time the reset button has to be pressed to reset (in ms)
const int hitIndicatorTime = 200; // time the hit indicator LED turns off when getting shot at (in ms)
// pins
byte triggerPin = 2;
byte reloadPin = 3;
byte resetPin = 13;
byte irPin = 9;
byte hitLedPin = 6;
byte buzzerPin = 7;
byte receiverPin = 4;
byte redPin = 11;
byte greenPin = 5;
byte bluePin = 10;
byte pinsSegments[7] = {A0, A1, A2, A3, A4, A5, 12};
// IR communication
IRsend irsend; // setup IR transmitter
IRrecv irrecv(receiverPin); // IR receiver
decode_results results; // results variable
const unsigned long irSendHex = 0xFFA25D; // define hex value to send
// arrays of digits for 7 segment display
const bool digits[10][7] = {
{0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 1, 1, 1, 1},
{0, 0, 1, 0, 0, 1, 0},
{0, 0, 0, 0, 1, 1, 0},
{1, 0, 0, 1, 1, 0, 0},
{0, 1, 0, 0, 1, 0, 0},
{0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 1},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0}
};
// reload animation on 7 segment display
const bool reloadAnimation[6][7] = {
{0, 1, 1, 1, 1, 1, 1},
{1, 0, 1, 1, 1, 1, 1},
{1, 1, 0, 1, 1, 1, 1},
{1, 1, 1, 0, 1, 1, 1},
{1, 1, 1, 1, 0, 1, 1},
{1, 1, 1, 1, 1, 0, 1}
};
const int animationLength = 6;
const int animationInterval = 100;
// array of colors to display health on RGB LED
const byte healthColors[11][3] = {
{ 0, 0, 0 },
{ 255, 0, 0 },
{ 255, 10, 0 },
{ 255, 20, 0 },
{ 255, 30, 0 },
{ 255, 50, 0 },
{ 255, 86, 0 },
{ 255, 122, 0 },
{ 255, 186, 0 },
{ 202, 255, 0 },
{ 0, 255, 0 }
};
// melody to play when being hit
const int hitMelody[2] = {
500,
600
};
const int melodyLength = 2;
const int melodyInterval = 150;
// shoot sound effect
const int shootSoundStartTone = 1000;
const int shootSoundEndTone = 700;
const int shootSoundInterval = 1;
// other variables
int health = maxHealth;
int ammoCount = maxAmmo;
bool alive = true;
unsigned long lastShot = shootCooldown*-1;
unsigned long startedReload = reloadTime*-1;
bool reloading = false;
unsigned long startedResetting = 0;
bool resetting = false;
unsigned long millisStartedTone = 0;
bool playingMelody = false;
int currentToneIdx = 0;
bool playingShootSound = false;
unsigned long millisStartedFrame = 0;
int currentFrameIdx = 0;
unsigned long millisStartedHit = 0;
bool hitIndicator = false;
// reset function
void(* reset) (void) = 0;
// function to display digits on the 7 segment display
void displaySegments(bool segments[7]) {
for(byte seg=0; seg<7; seg+=1) {
digitalWrite(pinsSegments[seg], segments[seg]);
}
}
// function to display health on the rgb led
void displayHealth(int hp)
{
analogWrite(redPin, healthColors[hp][0]);
analogWrite(greenPin, healthColors[hp][1]);
analogWrite(bluePin, healthColors[hp][2]);
}
void playGameOverSound() {
int gameOverTones[] = { 622, 587, 554, 523 };
for(int i=0; i<4; i++) {
if(i < 3) {
tone(buzzerPin, gameOverTones[i]);
delay(300);
noTone(buzzerPin);
} else {
// make the sound wavy
for (int i2 = 0; i2 < 10; i2++) {
for (int pitch = -10; pitch <= 10; pitch++) {
tone(buzzerPin, gameOverTones[i] + pitch);
delay(5);
}
}
noTone(buzzerPin);
}
}
}
void setup()
{
// setup pins
pinMode(triggerPin, INPUT_PULLUP);
pinMode(reloadPin, INPUT_PULLUP);
pinMode(resetPin, INPUT_PULLUP);
pinMode(irPin, OUTPUT);
pinMode(hitLedPin, OUTPUT);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
for(byte i=0; i<7; i+=1) {
pinMode(pinsSegments[i], OUTPUT);
}
// start IR receivers
irrecv.enableIRIn();
// GAME SETUP
displaySegments(digits[ammoCount]); // display ammo count
displayHealth(health); // display health
digitalWrite(hitLedPin, HIGH); // turn on hit indicator LED
// play startup sound effect
int startTones[] = { 196, 262, 330, 392 };
for(int i=0; i<4; i++)
{
tone(buzzerPin, startTones[i]);
delay(200);
}
noTone(buzzerPin);
}
void loop()
{
unsigned long currentMillis = millis();
alive = health>0;
// display ammo count
if(!reloading) {
displaySegments(digits[ammoCount]);
}
// display health
displayHealth(health);
// play sounds
if (playingMelody) {
if (currentMillis - millisStartedTone >= melodyInterval) { // we are playing a melody, check if we finished playing current tone
if(currentToneIdx+1 == melodyLength){ // we finished playing a tone, check if we finished the melody
// end of melody
noTone(buzzerPin);
playingMelody = false;
// if dead play game over sound
if(!alive) {
delay(100);
playGameOverSound();
}
} else { // we haven't finished the melody
// play next tone
currentToneIdx++;
millisStartedTone = currentMillis;
tone(buzzerPin, hitMelody[currentToneIdx]);
}
}
} else if (playingShootSound) {
if (currentMillis - millisStartedTone >= shootSoundInterval) {
if(currentToneIdx <= shootSoundEndTone) {
// end of melody
noTone(buzzerPin);
playingShootSound = false;
} else {
// play next tone
currentToneIdx -= 1;
millisStartedTone = currentMillis;
tone(buzzerPin, currentToneIdx);
}
}
}
// play reload animation
if (reloading) {
if (currentMillis - millisStartedFrame >= animationInterval) { // we are playing reload animation, check if we finished playing current frame
// play next frame
currentFrameIdx++;
// cycle to start if reached end of animation
if (currentFrameIdx > animationLength-1) {
currentFrameIdx = 0;
}
millisStartedFrame = currentMillis;
displaySegments(reloadAnimation[currentFrameIdx]);
}
}
// check if hit indicator LED has been off for enough time (only if still alive)
if (hitIndicator && currentMillis - millisStartedHit >= hitIndicatorTime && alive) {
hitIndicator = false;
digitalWrite(hitLedPin, HIGH); // turn LED back on
}
// input: reset
if (digitalRead(resetPin) == LOW) {
if(resetting) { // check if we were already holding the reset button
if(currentMillis - startedResetting >= resetTime) { // check if we held the reset button for enough time
reset();
}
} else { // start a new timer when we press it
startedResetting = currentMillis;
resetting = true;
}
} else {
resetting = false;
}
// stop here if dead
if(!alive) {
return;
}
// input: shoot
if (digitalRead(triggerPin) == LOW && ammoCount > 0 && !reloading && currentMillis - lastShot >= shootCooldown)
{
// SHOOT
irsend.sendNEC(irSendHex, 32); // send IR
irrecv.enableIRIn(); // restart IR receiver
ammoCount--;
lastShot = currentMillis;
// SHOOT SFX
currentToneIdx = shootSoundStartTone;
millisStartedTone = currentMillis;
tone(buzzerPin, currentToneIdx);
if(playingMelody) {
playingMelody = false;
}
playingShootSound = true;
}
// input: reload
if (digitalRead(reloadPin) == LOW && ammoCount < maxAmmo && !reloading) {
reloading = true;
startedReload = currentMillis;
// RELOAD ANIMATION
currentFrameIdx = 0;
millisStartedFrame = currentMillis;
displaySegments(reloadAnimation[currentFrameIdx]);
}
// reload gun
if (reloading && currentMillis - startedReload >= reloadTime) {
ammoCount = maxAmmo;
reloading = false;
}
// check if receiving IR signal (getting shot)
if(irrecv.decode(&results)) {
irrecv.resume(); // resume to receive other values
health--; // lose hp
// hit indicator LED
hitIndicator = true;
digitalWrite(hitLedPin, LOW); // turn LED off
millisStartedHit = currentMillis;
// GETTING SHOT SFX
currentToneIdx = 0;
millisStartedTone = currentMillis;
tone(buzzerPin, hitMelody[currentToneIdx]);
if(playingShootSound) {
playingShootSound = false;
}
playingMelody = true;
}
}
[EDIT]
Here is the ORIGINAL GITHUB sketch in a simulation. Not working (HIT always ON).
For WOKWI.COM:
diagram.json
{
"version": 1,
"author": "Anonymous maker",
"editor": "wokwi",
"parts": [
{ "type": "wokwi-arduino-nano", "id": "nano", "top": -4.8, "left": -0.5, "attrs": {} },
{
"type": "wokwi-pushbutton",
"id": "btn1",
"top": -51.4,
"left": 144,
"attrs": { "color": "red" }
},
{
"type": "wokwi-pushbutton",
"id": "btn2",
"top": -99.4,
"left": 144,
"attrs": { "color": "green" }
},
{
"type": "wokwi-pushbutton",
"id": "btn3",
"top": -147.4,
"left": 144,
"attrs": { "color": "blue" }
},
{
"type": "wokwi-text",
"id": "legendservo1",
"top": -144,
"left": 211.2,
"attrs": { "text": "RESET" }
},
{
"type": "wokwi-text",
"id": "legendservo2",
"top": -48,
"left": 211.2,
"attrs": { "text": "TRIGGER" }
},
{
"type": "wokwi-text",
"id": "legendservo3",
"top": -96,
"left": 211.2,
"attrs": { "text": "RELOAD" }
},
{ "type": "wokwi-7segment", "id": "sevseg1", "top": 129.78, "left": 158.68, "attrs": {} },
{
"type": "wokwi-rgb-led",
"id": "rgb1",
"top": -140,
"left": -75.7,
"attrs": { "common": "cathode" }
},
{ "type": "wokwi-led", "id": "led1", "top": -186, "left": 3.8, "attrs": { "color": "white" } },
{ "type": "wokwi-led", "id": "led2", "top": -186, "left": 51.8, "attrs": { "color": "red" } },
{ "type": "wokwi-ir-receiver", "id": "ir1", "top": -250.95, "left": 103.82, "attrs": {} },
{ "type": "wokwi-vcc", "id": "vcc1", "top": -191.24, "left": 259.2, "attrs": {} },
{
"type": "wokwi-resistor",
"id": "r2",
"top": 61.55,
"left": 96,
"attrs": { "value": "330" }
},
{
"type": "wokwi-resistor",
"id": "r3",
"top": 71.15,
"left": 96,
"attrs": { "value": "330" }
},
{
"type": "wokwi-resistor",
"id": "r4",
"top": 80.75,
"left": 96,
"attrs": { "value": "330" }
},
{
"type": "wokwi-resistor",
"id": "r5",
"top": 90.35,
"left": 96,
"attrs": { "value": "330" }
},
{
"type": "wokwi-resistor",
"id": "r6",
"top": 99.95,
"left": 96,
"attrs": { "value": "330" }
},
{
"type": "wokwi-resistor",
"id": "r7",
"top": 109.55,
"left": 96,
"attrs": { "value": "330" }
},
{
"type": "wokwi-resistor",
"id": "r8",
"top": 119.15,
"left": 96,
"attrs": { "value": "330" }
},
{
"type": "wokwi-resistor",
"id": "r1",
"top": -92.05,
"left": -38.4,
"attrs": { "value": "330" }
},
{
"type": "wokwi-resistor",
"id": "r9",
"top": -82.45,
"left": -38.4,
"attrs": { "value": "330" }
},
{
"type": "wokwi-resistor",
"id": "r10",
"top": -72.85,
"left": -38.4,
"attrs": { "value": "330" }
},
{
"type": "wokwi-text",
"id": "legendservo4",
"top": -192,
"left": 57.6,
"attrs": { "text": "HIT" }
},
{
"type": "wokwi-text",
"id": "legendservo5",
"top": -192,
"left": 9.6,
"attrs": { "text": "IRtx" }
},
{
"type": "wokwi-text",
"id": "legendservo6",
"top": -134.4,
"left": -76.8,
"attrs": { "text": "HEALTH" }
},
{ "type": "wokwi-ir-remote", "id": "remote1", "top": -144, "left": -240, "attrs": {} },
{
"type": "wokwi-text",
"id": "legendservo7",
"top": -278.4,
"left": 115.2,
"attrs": { "text": "IRrx" }
}
],
"connections": [
[ "nano:GND.2", "btn1:2.l", "black", [ "v0" ] ],
[ "nano:GND.2", "btn2:2.l", "black", [ "v0" ] ],
[ "nano:GND.2", "btn3:2.l", "black", [ "v0" ] ],
[ "nano:2", "btn1:1.l", "green", [ "v0" ] ],
[ "nano:3", "btn2:1.l", "green", [ "v0" ] ],
[ "vcc1:VCC", "sevseg1:COM.2", "red", [ "v230.4", "h-86.4" ] ],
[ "nano:A0", "r8:1", "green", [ "v0" ] ],
[ "nano:A1", "r7:1", "green", [ "v0" ] ],
[ "nano:A2", "r6:1", "green", [ "v0" ] ],
[ "nano:A3", "r5:1", "green", [ "v0" ] ],
[ "nano:A4", "r4:1", "green", [ "v0" ] ],
[ "nano:A5", "r3:1", "green", [ "v0" ] ],
[ "nano:13", "r2:1", "green", [ "v0" ] ],
[ "sevseg1:A", "r8:2", "green", [ "v0" ] ],
[ "sevseg1:B", "r7:2", "green", [ "v0" ] ],
[ "sevseg1:C", "r6:2", "green", [ "v9.6", "h19.2", "v-105.6" ] ],
[ "sevseg1:D", "r5:2", "green", [ "v19.2", "h48", "v-124.8" ] ],
[ "sevseg1:E", "r4:2", "green", [ "v28.8", "h67.2", "v-144" ] ],
[ "sevseg1:F", "r3:2", "green", [ "v0" ] ],
[ "sevseg1:G", "r2:2", "green", [ "v0" ] ],
[ "nano:GND.2", "rgb1:COM", "black", [ "v-19.2", "h-76.8" ] ],
[ "r10:2", "nano:11", "green", [ "v0", "h8.4" ] ],
[ "r9:2", "nano:5", "green", [ "v0", "h75.6" ] ],
[ "r1:2", "nano:10", "green", [ "v0", "h18" ] ],
[ "rgb1:R", "r10:1", "green", [ "v0" ] ],
[ "rgb1:G", "r9:1", "green", [ "v0" ] ],
[ "rgb1:B", "r1:1", "green", [ "v0" ] ],
[ "nano:GND.2", "led2:C", "black", [ "v-19.2", "h-201.6" ] ],
[ "led2:A", "nano:6", "green", [ "v67.2", "h134.4" ] ],
[ "nano:GND.2", "led1:C", "black", [ "v-19.2", "h-249.6" ] ],
[ "nano:9", "led1:A", "green", [ "v0" ] ],
[ "nano:GND.2", "ir1:GND", "black", [ "v0" ] ],
[ "vcc1:VCC", "ir1:VCC", "red", [ "v9.6", "h-124.8" ] ],
[ "ir1:DAT", "nano:4", "green", [ "v19.2", "h-38.4" ] ],
[ "nano:12", "btn3:1.l", "green", [ "v-9.6", "h-19.2", "v-124.8" ] ]
],
"dependencies": {}
}
You have this error
'currentMillis' was not declared in this scope
Also, I used CTRL+F to search for unsigned long currentMillis and it does not appear anywhere in your sketch. So EDIT that explains the aforementioned error. You have to declare it somewhere. Same for melodyInterval. It is also not declared anywhere. And melodyLength.
Your curly braces are wrong in void loop().
Did you know that if you click immediately to the right of a bracket or curly brace, the IDE will automagically put a little rectangle around its mate?
EDIT: forget it. See post #15 @xfpd
See original sketch (post 15) versus edited sketch (post 1).
yeah, just did and edited my reply after I saw yours
Which is hurts less:
- Start with gitHub sketch and add new code
- Start with edited sketch in post 1 and move things around
This one looks "50/50" on effort.
and this changing "a lot" lead you here.
Change one small single thing and compile again to check if it does compile.
This strategy only seems to need more time. It will be much faster in the long run
because you always know the bug must be inside these 3 lines of code that you changed last.