G'day folks. So I previously posted for some help in writing the code for the Mk85 Iron Man helmet I printed. I've been watching tutorials til the cows come home and finally managed to put together a code to open the servos (faceplate) and turn off the LEDs, and close the servos (faceplate) and blink the LEDs 3 times then fade on and stay on (until faceplate goes back to open position). BUT! as you can see in the vid attached it's totally RANDO in how it does it. The switch isn't responding even though I have it all wired correctly, and the whole things is just doing what it wants randomly. I think I'm missing something in the code in how to tell it to work with the button. But still being very new to it all, I don't know enough to see where I have it wrong. If anyone has a good eye for code, can you please tell me what I have wrong in mine and how to fix it? Would really appreciate if someone can please help me get this coding over the finish line. Doing my head in! I've attached the code in txt form as well as the vid of the rando movements it's doing. Oh and I'm using the TowerPro Mg90s and Ive got an Arduino Uno.
#New to coding and still needing help please.
5 messages · Page 1 of 1 (latest)
Hey @blazing falcon, thank you for contributing to this forum.
Please provide as much information (images, video, description) as you can. This will increase the chance that someone can help you with your issue.
Use the Close button when your issue is resolved.
This is a C thread issue I think. Threads are a 2nd year class not easily simplified. If I read the code right, function loop should be repeatably called and maintain its own state.
You are not the only game the arduino is running, so it will call loop then forget about you until the next tick. You are acting like you are the primary program and your order is the only order.
you have 3 separate functions with different delays, so after many calls to loop, you've got multiple delays and function calls in the stack causing the apparent random functions.