How to write only once to Serial

This is my first post, and I’m hoping for some guidance on an issue on my current project.

The scenario is that I’m building a hexapod and want to control it via a PS4 controller. I have everything working together and have hit a snag with the code repeating itself. I’ve narrowed my issue down to something that seems like it should be a simple fix, but I’m having no luck.

I can trigger the single leg I have hooked up with the PS4 controller LeftHatY just fine, the snag happens after the code runs.

if(PS4.getAnalogHat(LeftHatX)<10)
      {
// do stuffs
}

However, after running, the system seems to have a buffer of repeated triggers that will send until the buffer is clear. This reminds me of a debounce scenario on a analog button but haven’t seen anyone else reporting the same issue.

Any ideas on what I’m missing?

can you send your full code, please? I too am a beginner but I am willing to help.

Post ALL the code, using code tags. State what you expect to happen, and what happens instead.

haven't seen anyone else reporting the same issue.

What issue? All you have said is that something happens repeatedly. The problem is in the code you didn't post.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.