There are several good articles on Instructables about building your own Arduino. Depending on your horde of electrical parts, you may be able to build an Arduino clone for as little as $3. I recently built two: one on a solderless breadboard and another that is like a USB-stick made on perfboard and my parts cost were approximately $7 (the breadboard parts were sacrificed to build the stick after I got all the hardware and software working.)
Once you get your CloneDuino built, or even if you purchase a commercial model such as the UNO (picture #5), then you need to do some programming for the next step down the path of creating something useful or fun. BUT, what if you could use the Arduino for gathering the state of digital or analog information and then log that data to the PC for later manipulation? This would mean that the Arduino software would not need to be changed (or perhaps only minor changes) to perform many experiments.
Step 1: Building the USB Hardware Interface
The interface built by rancidbacon for his tests is shown in the first picture.
The schematic for the interface is shown in the second picture.
To be successful with this project, you will need to construct this circuit in some manner, either as shown here or as I showed in the previous section. While the construction is not complicated, errors will keep the V-USB software from working (said another way, the project will be a BIG flop and will not work.) Additionally, if you have a wiring accident, diode reversed, improper parts selection, or cold solder joints, the circuit is likely to not work. AT WORST, IMPROPER CONSTRUCTION AND WIRING COULD DAMAGE YOUR PC USB PORT, SYSTEMBOARD, OR CREATE OTHER SERIOUS AND EXPENSIVE DAMAGE.
DO NOT ATTEMPT TO BUILD THIS INTERFACE AND USE IT ON YOUR PC UNLESS YOU ARE CONFIDENT YOU CAN CONSTRUCT THE CIRCUIT PROPERLY AND HAVE THE ABILITY TO TEST YOUR INTERFACE BEFORE CONNECTING TO YOUR PC. IF YOU MOVE FORWARD WITH CONNECTING TO YOUR PC YOU ASSUME ALL RISKS ASSOCIATED WITH THIS PROJECT.
Step 2: Download the V-USB Modified Code
The code should be integrated into your Arduino environment in the library section. On my XP machine, the location is:
Adjust your location (directories) to match the install requirements for Arduino on Linux or iOS.
Download and expand the ZIP file. The ZIP file is structured as:
Only the files in the \UsbKeyboard folder and subordinate folders are required to be moved to
Step 3: The Arduino UNO Code
The Arduino Sketch is contained in the attached ZIP file. This was a quick-n-dirty weekend project, so expect to see some spelling errors and some non-polished approaches to doing things (in the interest of getting results quickly!) There is a thread on the Arduino forum for this code, so if you embellish or significantly improve/revise the program, please feel free to post it so that everyone can benefit from your expertise:
Simply unzip to your Sketch folder and load into the Arduino GUI to program either by uploading over the serial or USB mapped Comm port or alternately using ICSP if you have an ATmega programmer.
Step 4: HID on the PC
All of the hardware and software that we have build and coded is designed to make the UNO (clone) "think" that it is a programmable USB keyboard. That is like having a keyboard with a brain. My code simply reads the state of all of the free Arduino pins and converts that information into a variable length string that can be "typed" across the USB interface.
HID does not require any external driver installation. The Windows PC, iMac, Linux PC all have the HID driver as part of the base operating system. This is so that the owner can go out and buy a new keyboard to use with an existing USB port.
The faux-keyboard information needs to be collected in an application. So open Notepad or a word processing program. Make certain that this window/program has "focus", that is, is the window where keystrokes are directed. Test by typing a letter or number before inserting your new USB Arduino keyboard.
After you plug the USB interface into a free USB port, WindowsXP will beep as soon as XP determines that the hardware is a USB keyboard. 10 seconds after the beep, the software will automatically start to interrogate the analog pins and the digital pins and send this information to the PC.
Your display will appear as:
SIMPLE HID DATA LOGGER USING VUSB WWW.OBDEV.AT
ARDUINO PORT BY RANCIDBACON.COM
UNO 328P EXAMPLE - RAY BURNETTE C20121210
DIGITAL 3L 6H 7L 8L 9L 10L 11L 12H
DIGITAL 3L 6H 7L 8L 9L 10L 11L 12H
Analog ports are numbered 0 - 5 and correspond to the same ports as the Arduino. Same is true of the free digital pins 3, 6, 7, 9, 10, 11, and 12. "H" means HIGH and "L" means LOW. I did not employ the internal pullups on the digital pins, so these pins are "floating" and both analog and digital signals will be registered from the environmental noise. When you connect your electronic switches or voltages to the Arduino, you will have a steady reading (or a reading that follows the signals.)
Step 5: What's Next?
For example, you can edit the Arduino program to simply print the value of a pin(s) and load that automatically into Excel. After some time period, you can save the data, manipulate the data, convert A/D values to real voltages by using the 0-1023 value that came over the keyboard and converting that to voltage:
( value received / 1023 ) * 5.0
Building formulas into Excel makes for some fancy graphing! I stripped out all of the labels in my code, sent two values over the V-USB port to Excel, converted to voltage, and was able to plot a graph in real-time (I set my input range to extend into empty cells that were filled-up over time.)
Another interesting thought is that you can save the data to an ASCII file. Open up a DOS or COMMAND window under XP/Vista/Win7/Win8 and type the command:
COPY CON filename.txt
When you press the ENTER key, the file will be created and the logging will continue automatically until you type Ctrl-Z (control Z or ^Z) when the file will be closed and available for other processing. In fact, the COPY CON <filename.txt> ENTER can all be typed automatically by the V-USB device. Clever, ugh? If your Arduino has a RTC, real time clock, shield, you can even timestamp data.
Step 6: Addendum
Step 7: Addendum 2
As mentioned in the main article, the HID enabled Arduino can "type" into Notepad or even Excel. However, the input data is a string of characters. Sure would be nice if we could (easily) parse that information: Analog values turned into Volts and logic values turned into 0's and 1's.
Easy. The attached Excel Zip file has an example of how to build the formulas to do exactly that. You can extend this idea and build yourself a large input template... large enough to extend into several hours or recording.