Simple switch to PC interface to write to text file.

First post and a novice. I’m not even sure what the right terms are to search so please feel free to offer search terms if similar projects already exists.

In simple terms I want to interface a simple switch similar to push-to-talk type switch to interface with a PC so that pushing the switch causes a piece of defined text to be written to a text file. For example the date and time the button was pushed. There is the start of a much larger project but this is the essence. Any clues where I start?

I have done some very simple Arduino projects so I’m hoping I’ve got at least the basic skills to tackle this.


For example the date and time the bottom was pushed.

Be sure to get the owner’s permission first :slight_smile:

For what you want you need a program on the Arduino to send a message to the PC (could be as simple a “”) when the button is pressed and a program running on your PC that listens for that message and does whatever you want when it detects the Arduino message.

This Python - Arduino demo may help get you started. I believe it will work on Windows if you edit the reference to the serial port.

Of course you can do the same thing with any PC programming language.


Be sure to get the owner’s permission first :slight_smile:

Ah the dangers of dashing off a post on a phone. :stuck_out_tongue_winking_eye:

Thanks Robin. I will have a good look through the reference and get going.

The Leonardo, and Micro, can act as keyboards, so reading the state of a switch, determining that it changed state, and sending keystrokes to the PC would be trivial.

Of course, the Arduino has no idea what time it is (without extra hardware) so sending the date and time could be a problem. 8)