Start a loop function with pressing a key

hi, i want some example like: i want to choose a key on my keyboard that is connected to my computer (like "Left_ALT") , then when i press that key my script gonna start for example when i press "Left_ALT" script gonna print "number 1 to number 9"

You will need to write a program for the PC that will send a message to the Arduino when the key is pressed.

Can u explain more?

Your computer already has things that it does, in the various programs on it, when you hit specific keys. If you want it to do something else then you need to write your own program that maps the key to a signal to your arduino. That could be serial communication through USB for example. Of course, the arduino IDE has a serial monitor and you could just use this to send a signal to your arduino.

Your question is so vague as to have no more specific answer

The keyboard is connected to the PC. It is not connected to the Arduino. If you want the Arduino to do something when a key is pressed, the PC will have to tell the Arduino when the key is pressed.

1 Like

I wonder how well that's working with the left alt key :smiley:

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