I am a novice at electronics hacking. I would like to know how I can make a circuit communicate with a PC. Take for example, a simple circuit, with one LED and a switch. The switch on the circuit however, is not used to control the LED. Pressing it communicates the present state of the LED. I have a program running on my computer, which has for an UI, a button and a graphic object; a black filled circle.

  • I should be able to turn the LED on and off from my computer by clicking the button on the screen.
  • Pressing the switch on the board, should communicate to the program the state of the LED. If the LED is on, the black circle should turn green, else it should turn black.

This a hypothetical situation I have described to explain the problem. I am not looking for a solution to implement this thing, but want to know how this communication between my circuit and the computer can be achieved, in a simple, inexpensive way, over

  1. wire?
  2. wireless?

And if you could suggest where I should look and what I should learn to get started with my electronics project, that would be of great help.


There are quite a few different ways you could achieve this. Here are a few:

  1. You could program a small microcontroller like a Microchip PIC16F84A to watch the button and the LED. Whenever the button is pressed, the PIC16F84A sends a character through a FTDI serial chip to a USB port on your computer. On your computer, a program written in Processing watches the USB port and updates the pictures on the screen. Total cost: $20 for some chips and a breadboard.

  2. You could buy a Bluetooth Arduino with a prototyping shield. The Arduino talks over a Bluetooth chip to a Bluetooth card in your PC. A program written in Python listens to the Bluetooth card and draws the appropriate picture on the screen with the Pygame library. Total cost: $150 for a Bluetooth Arduino.

  3. You could attach a webcam to your PC that watches your LED and the button. A program written in Ruby is analyzing every image coming from the webcam, comparing it to the previous image. When it detects a change in the region of the image near the button, it looks at the color of the pixels in the LED region and updates a value in a database. A webpage auto-refreshes using the jQuery timer plugin, and updates an image on the screen based on the value in the database. Total cost: $25 for a crappy webcam.

  4. You could find an old PC with a parallel port and install Ubuntu Linux on it. You connect the LED and the button to pins on the parallel port and then write a program in C that reads address 0x378. Based on the data returned, it makes calls into a C graphics library that does the appropriate screen drawing. Total cost: free, if you can find a PC old enough.

  5. You replace the power button on your computer with the button in question, and the power LED with the LED in question. You replace your BIOS with a version of OpenBIOS that has been modified to display a green circle on the screen, and never boot any operating system. Total cost: probably the cost of a new PC.

But in all seriousness

I think I'd recommend an Arduino and Processing. They're simple and great for beginners. Total cost: $30 for the Arduino.

Best of luck.

  • \$\begingroup\$ You don't need a special BIOS to read the state of the power button. You should be able to do it from Linux without any kernel hacking or anything. I'm pretty sure you can configure what happens when the power button gets pressed. \$\endgroup\$ – davr Aug 3 '10 at 15:19
  • 2
    \$\begingroup\$ I think Arduino and Processing should be the best way to start. \$\endgroup\$ – sauparna Aug 3 '10 at 18:27

Go get the book "Making Things Talk" by Tom Igoe: http://oreilly.com/catalog/9780596510510

It's not about speech, it's about all the different methods of making your different devices-- e.g., your computer and your circuit --talk to each other. In it, you'll find the gory details of all the methods people are outlining in the other answers here, complete with circuit diagrams and source code (where appropriate).

If you'd like to learn any or all the different ways to do this, you couldn't have a better starting point.


Python + FT245

Drop the PyUSB module, and suddenly it takes only three lines (well, four, if you include the import) of code to get Python talking to meatspace through 8 Parallel IO lines.

import d2xx
hardwareHandle = d2xx.open(0)
#Open the First FTDI device on the computer
hardwareHandle.setBitMode(0xff, 0x01)      
#Put the hardware in Async Bit-bang mode, set all pins as outputs

#And suddenly
#`data` shows up on the FT245 pins!

hardwareHandle.setBitMode(0x00, 0x01)
#set the IO lines to inputs (the first byte is the IO mask)
input = hardwareHandle.read()
#and input is equal to the value on the IO lines!

It's dead-simple parallel IO from a high-level language.

As a bonus, the hardware costs a total of $17.95


Take a look at the TI Chronos

TI makes this awesome 16 bit microcontroller family based on the MSP430 chip. One variant of that chip is the CC430, which has wireless embedded in the package.

The chronos is a "development board" that they sell for 49 bucks. It comes in a wrist watch form factor (which I use everyday, it's even fashionable outside the geek world :-)) It also comes with two USB dongles, one for the JTAG (programmer) and another one is the wireless counterpart.

One of the examples in the devboard is controlling the mouse wirelessly using the watch, which is pretty cool. The watch also comes with accelerometer, barometer (altitude) sensor and thermometer.

  • \$\begingroup\$ My Chronos is coming on Friday! Seriously, though, this is just a slightly more complex form of the PIC -> FTDI setup. \$\endgroup\$ – Kevin Vermeer Aug 3 '10 at 10:57

Wired or wireless is pretty straightforward these days. You can get bluetooth kits that give you I/O already, and you can also buy very inexpensive USB I/O boards. What you want to use is entirely up to your needs and your budget.


Something like that (never used it, no affiliation with the company) would probably get you off and running very quickly and with a minimum of fuss. They appear to be available from Digikey and Mouser, and probably others as well.


Assuming that your PC has a serial port you could just use the USART on the chip and an RS-232 transceiver to communicate between the chip and the PC. If your PC doesn't have a serial port you should invest in a USB<->RS-232 converter.


If you're main interest is to get it up and running quickly, there is a bunch of USB-based digital I/O kits which include programming libraries to read/write the states of the pins. Unlike working with Arduino or other micro-boards, this means you only have to worry about programming the PC (versus having to write and debug the code running on the microcontroller board).

It used to be that wiring inputs and outputs through a PC's joystick or parallel port was the way to go. But that was in the days of DOS and Windows up to about Windows 95. Since then, directly accessing the registers to get to the hardware has gotten progressively harder to do. That said, it's still do-able - you just will have to jump through programming hoops to get to those pins from your program. My ThinkPad's laptop dock, for example, has the legacy style parallel port, and it is still supported by the OS, should I decide to plug in a LaserJet II. :)


There are some nice simple USB devices which can do this, for example the Kadtronics USB Digital I/O Commander.


Your quickest and easiest method of doing that would be via Labview and associated USB I/O devices. Of course, this isn't cheap (thousands of dollars). What you're describing is not entry level, definitely not 'Hello World'-level.

Other than spending that much money, you'd probably be best with using an Arduino and communicating with your program via serial and having the Arduino turn the light on and off.

  • \$\begingroup\$ Oh boy, it's not as easy as I thought it would be. Thanks for this perspective. \$\endgroup\$ – sauparna Aug 3 '10 at 18:32
  • \$\begingroup\$ There is a LabVIEW Home Bundle (licensed for noncommercial hobbyist/maker use) available for $50. This can be used with Arduino, Raspberry Pi, or other low-cost boards to create I/O from a computer, or create embedded software to run on the board. While probably overkill for this particular problem compared to other answers, the cost is reasonable and the tools should be very capable of much more complex uses. \$\endgroup\$ – mbmcavoy May 6 '16 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.