how to execute something on arduino by pressing a button on a computer keybaord

Is it possible to execute a sequence by pressing a letter on the keyboard. For example, getting an LED to flash to flash twice when you press the space key? If it is could you put in an example coding as I am new to arduino and not familiar with the terms or how to use things.

Assuming the Arduino is connected through the USB serial cable you would have to write a program to run on the PC to send characters to the Arduino. The reception of those characters can trigger whatever behavior you want in the Arduino.

This example code is built into the IDE under examples > communications

This Python - Arduino demo illustrates how to communicate between a PC and an Arduino. The Python program could easily be adapted to send a message when a particular key is pressed.


I would start with this link: available(). Be aware that the example code displays the decimal value of the character that is received. Use e.g for a bit of understanding.

Next you might want to read Serial Input Basics - Updated