Go Down

Topic: Stuck in loop? (Read 762 times) previous topic - next topic

Napalm1432

Jun 15, 2015, 01:43 pm Last Edit: Jun 16, 2015, 06:16 pm by Napalm1432
Hello, i'm currently working on a robot project, it's a pretty simple robot, it can move 5 servos, detect when someone walks by (pir motion sensor) and play sounds from a serial mp3 board, and also a wii nunchuck attached to override the sensor when i want to take manual control.

Now all the individual components work, and i created a script to do the multitasking, which partly works. and that's why i'm here, some things aren't working as they're supposed to. Right now the issue is that it checks for nunchuck input, nut somehow it constantly registers all buttons to be pressed and keeps stuck in that loop. even though before the nunchuck behaved as it should.
Could someone review my code and see if i made some mistakes or if there's a better solution to it?



Napalm1432

Okay so i resolved most of the issue, i removed the "else" part in the main loop, and noticed i actually reversed 2 pins for the nunchuck.
so now i can use the nunchuck for commands again.
Now i have a function called CheckSensor, and when i put this anywhere in my main loop it doesn't run it anymore..
soo if there's any solution to that, i would love to hear

PaulS

Quote
Now i have a function called CheckSensor, and when i put this anywhere in my main loop it doesn't run it anymore..
"it" is a pronoun. You used it twice in that sentence. Neither time does it refer to anything.

You changed your code. You get to post it again.

The art of getting good answers lies in asking good questions.

Napalm1432

I uploaded the updated code

PaulS

Quote
I uploaded the updated code
So, now we can compare your current code to your previous code, to see what you changed, right?

DO NOT DO THAT AGAIN!!!!
The art of getting good answers lies in asking good questions.

Napalm1432

So, now we can compare your current code to your previous code, to see what you changed, right?

DO NOT DO THAT AGAIN!!!!
Got it, can you clarify exactly why not to do it again, and how i SHOULD do it.
I can't say i'm a programmer so i don't know how you guys work.

PaulS

Quote
I can't say i'm a programmer so i don't know how you guys work.
It is not a matter of being a programmer or not. It is a matter of keeping the original code in the original post and changes in the replies. Put the original code back in the original post. Put the revised code in the next reply.
The art of getting good answers lies in asking good questions.

Go Up