Wednesday, January 21, 2009

Arduino Oscilloscope



If you are interested in electronics and haven't heard about Arduino yet then you should definitely check it out. I got a Duemilanove for Christmas and it's been great fun so far. Before I bought the Harmony 880 the wheels in my head started spinning, I was thinking about how I could use Arduino to make a Universal Remote. I found an article that discussed how to start making one and what the code would look like. Sadly I don't have an oscilloscope and don't plan on spending the money for one anytime soon either. With more wheels turning I researched making an oscilloscope with the Arduino and found another article on how to do this. So now I'll show you what I've done so far to create an Arduino Oscilloscope.

First you do need to have the Arduino IDE and Processing installed on your machine (both pieces of software will run on PC, Mac and Linux). Then go to the Poor Man's Oscilloscope post and download the .PDE file that holds the processing and Arduino code. Open that file with a text editor and copy the bottom section that starts after the line
          '// The Arduino code.'
and paste that into the Arduino IDE. Now you need to hook the Arduino up to the computer and upload the sketch to the board. If this is the first sketch you are uploading I would suggest buying 'Getting Started with Arduino' by Massimo Banzi (one of the creators of the Arduino Board). There is also a getting started guide on the Arduino website. Select your operating system on the left side and that will get you up and running.

Now you need to add your sensor to Analog Pin 0 and the Vin pin. If you are trying to make an IR Decoder for the Universal Remote project you will you the IR Phototransistor into the board.

Now close the Arduino IDE and open Processing. Start a new sketch and paste in the top portion of the code from the .PDE file you downloaded (This will be all but the part we used before). You may have to change the serial port number depending on what port your Arduino is plugged into on your computer. Count the number of ports above the one you are using to connect your Arduino (not including the Arduino port) and change the line that reads:
          'port = new Serial(this, Serial.list()[0], 9600);'
change [0] to however many ports are above the one you used in the Arduino IDE to connect to the board. Run the Processing sketch and it should show you a real time graph of the input. It would probably be a good idea to test the program by doing something similar to the video above. Insert an LED and turn the lights on and off to see if you get any movement in the graph.

That should be about all you need to know. Use the comment section to discuss how you modified this project or any other Arduino projects that you've been working on.

No comments: