how to make an if statement print to serial once

Dear Reader,

i am using an IR remote to control my arduino uno, i have just one question, what is the best way to use a button on an IR Remote to mimic me hitting the space bar on my computer. I run windows 8 if that makes any difference.

Welcome to the forum.

i have just one question

yes you might, but reading and trying to decipher your questions leads the rest of us to have many.

what is the best way to use a button on an IR Remote to mimic me hitting the space bar on my computer

This question is so vague, I have no idea where or what the Arduino has to do with this, and what has windows whatever got to do with this?

If I were to take your question literally, then one of the best ways to use a button on a remote control, IR or otherwise is to use your finger, that is what remote controls are for generally.

Are you asking how best to make the sound of you 'hitting' the space bar on your poor computer or the location or what, I have no idea and I expect no one will either.

All we can do is guess at your vague question.


Paul

Are you using a Leonardo to send keyPresses to your PC ?

The usual way to do a thing once is to have a variable to record that it has been done

if (! keySent) {
   sendKey()
   keySent = true;
}

...R

Hi, welcome to this forum,

When experimenting with IR-remotes, I noticed they can send the same command several times in a short period, when pressing a button. If that’s the problem, it can indeed be hard to push a button and get one result only.

You could scan for IR-data in that case and add a short delay after you received a valid code, to get enough time to release the button.