Wednesday, 6 May 2015

wireless - What are the ways I can make my circuit communicate with a computer?


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.



Answer



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.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...