I'm trying to make my Arduino elegoo uno r3 robot car v2.0 use the IR remote to line track basically I want to push for instance the 1 button and it start the line track function for some reason which I have no idea what I'm doin lmao. can get this simple task to perform right ive tried switch loops and I cant get it any help would be appreciated
Posting the same question in different parts of the forum will earn you no friends here, so I deleted the duplicate of this topic to save your embarrassment.
Please remember to use code tags when posting code
well that's the thing ive wrote it like 5 different ways that's just the last one I wrote when I kinda gave up after like 6hrs of writing and trying to make it work all I want is when I press a button don't really care what button I just want it to line track after the button is pressed. like I said I'm a total noob so hey I except all the criticism
Don't have an IDE on my laptop so can't test it to make sure... but does that code even compile?! I can't even figure out what it is supposed to be doing just by looking at it.
wvmarle:
Don't have an IDE on my laptop so can't test it to make sure... but does that code even compile?! I can't even figure out what it is supposed to be doing just by looking at it.
instead of doing the digitalRead() clearly in the code (to make it easier to understand), that’s OK.
What is surprising is that the OP does not notice (even without understanding code) the syntactical singularity of one line versus the others constructs
It was so weird I got so confused I had no idea any more what it is supposed to be doing This forward is here used as variable while it's not declared as such, though there's a function called forward(). Calling a function without the () or an undeclared variable normally results in a compiler error.
wvmarle:
Calling a function without the () or an undeclared variable normally results in a compiler error.
You can't call a function without the (), but you can test for the existence (ie. function pointer non-null) of a function by missing out the parentheses.
Right. So for the workings of the code that becomes even worse - as it's an infinite loop.
That code feels more and more like it should have been submitted to the obfuscated C contest, rather than this forum
Ok so now that we understand I'm a dumbass.
can someone actually help me. All I want it to do is run the loop after I press the button all the car will do is drive forward Go Figure
The fact that you are starting does not make you a dumbass - we all started there
The question is more do you want to understand what you do and Learn something or do you expect someone to write the code for you?
If you want to learn - then I would suggest you write code to perform an active wait for the IR signal in the setup() (this code is in the loop at the moment)
Once you have received te signal - proceed to the loop() and let it spin
Assumptions made:
Button is wired between GND and pin 1.
Pin 2 set HIGH makes the robot move forward.
With those assumptions, what this code does: the moment you press the button the robot starts moving forward. That's it.
Ok so it is a robotic car that has IR,line tracking,ultrasonic, and bluetooth. I can make all of them run individually. But now I wanted to start combining them together.
So the code I want to write is to have the IR start the line tracking the LT1,LT2,<3 are the line sensors.
The loop is the line sensors task to perform I just cant get the remote to activate the loop it will either spaz out or just drive forward.