loading
Oscilloscopes are all so EXPENSIVE! So one day, December 4, 2011, I was thinking of something to do because I was bored and had done all of my schoolwork. I decided, because I have been wanting an Oscope (Oscilloscope) for a year now, but my parents never got around to buying me one, I just made one! With that said, being only 14 in 8th grade, I do not make much of an allowance, if not any. I thought that maybe sharing this with the world would be helpful for those, like me, do not either make much money or have a tough budget. Although I may have a simple Oscope, it does the job. Please read all of the instructions first.

Step 1: Supplies

There are not many supplies needed to build this Oscope, but you will need the following: an Arduino (any kind will work), a computer (just to program one thing and to see your Oscope, you will not need to use it for this project forever), and two jumper cables.

Step 2: Setting Up Arduino

All you need is you need out is your Arduino and your computer on both processing, and Arduino IDE. You can find these programs at processing.org and at arduino.cc. Plug your Arduino in and get ready to program! Use your two jumper cables by plugging one into RX and the other into GND on your Arduino. You will use these to make your Oscope work!

Step 3: Programming Processing

THIS IS THE PROCESSING PROGRAM! YOU WILL ALSO NEED TO ADD THE FONT TO THE DATA FOLDER THING... To add the font you go to Sketch -> Add File... -> then add my attached font.

/*
* Oscilloscope
* Gives a visual rendering of analog pin 0 in realtime.
*
*
* (c) 2011 "simonfrfr" (newtonlabs@bellsouth.net)
*/

import processing.serial.*;

color currentcolor;
boolean locked = false;
boolean Herr = false;
boolean serialt = false;
CircleButton circle1, circle2, circle3;
Serial port;  // Create object from Serial class
int val;      // Data received from the serial port
int[] values;
float zoom;
PFont fontA;

void setup()
{
  fontA = loadFont("Ziggurat-HTF-Black-32.vlw");
  textFont(fontA, 32);

  // Only draw once
  //noLoop();
  size(1280, 480);
 
  color buttoncolor = color(153);
  color highlight = color(102);
  ellipseMode(CENTER);
  circle3 = new CircleButton(50, 50, 50, buttoncolor, highlight);
  circle2 = new CircleButton(50, 50, 50, buttoncolor, highlight);
  circle1 = new CircleButton(50, 50, 50, buttoncolor, highlight);
  // Open the port that the board is connected to and use the same speed (9600 bps)
  port = new Serial(this, Serial.list()[0], 9600);
  values = new int[width];
  zoom = 1.0f;
  smooth();
}

int getY(int val) {
  return (int)(height - val / 1023.0f * (height - 1));
}

int getValue() {
  int value = -1;
  while (port.available() >= 3) {
    if (port.read() == 0xff) {
      value = (port.read() << 8) | (port.read());
    }
  }
  return value;
}

void pushValue(int value) {
  for (int i=0; i<width-1; i++)
    values[i] = values[i+1];
  values[width-1] = value;
}

void drawLines() {
  stroke(255);
 
  int displayWidth = (int) (width / zoom);
 
  int k = values.length - displayWidth;
 
  int x0 = 0;
  int y0 = getY(values[k]);
  for (int i=1; i<displayWidth; i++) {
    k++;
    int x1 = (int) (i * (width-1) / (displayWidth-1));
    int y1 = getY(values[k]);
    line(x0, y0, x1, y1);
    x0 = x1;
    y0 = y1;
  }
}

void drawGrid() {
  stroke(255, 255, 255);
  line(0, height/2, width, height/2);
  line(0, height/2+1, width, height/2+1);
  line(0, height/2+2, width, height/2+2);
  line(0, height/2+3, width, height/2+3);
  line(0, height/2+4, width, height/2+4);
  line(0, height/2+5, width, height/2+5);
}

void keyReleased() {
  switch (key) {
    case '+':
      zoom *= 2.0f;
      println(zoom);
      if ( (int) (width / zoom) <= 1 )
        zoom /= 2.0f;
      break;
    case '-':
      zoom /= 2.0f;
      if (zoom < 1.0f)
        zoom *= 2.0f;
      break;
  }
}

void draw()
{
  serialcheck();
  if (serialt == true) {
  if (Herr != false) {
  background(19, 134, 209);
  fill(255);
  text("- zoom out", 100, 60);
  text("+ zoom in", 100, 95);
  update(mouseX, mouseY);
  //circle1.display();
  //circle2.display();
  circle3.display();
  drawGrid();
  val = getValue();
  if (val != -1) {
    pushValue(val);
  }
  drawLines();
  }
  else {
        fill(42, 88, 87);
        rect(0, 0, 1280, 480);
        circle3.display();
        update(mouseX, mouseY);
  }
  }
     else {
  background(0);
  fill(255);
  text("SORRY, THE CONNECTION HAS BEEN LOST, ", 100, 60);
  text("ATTEMPTING TO CONNECT TO SERIAL PORT.", 100, 95);
  text("IF YOU RECONNECT YOUR SERIAL PORT AND THIS", 100, 130);
  text("MESSAGE DOES NOT GO AWAY THEN EXIT THE ", 100, 165);
  text("PROGRAM AND REOPEN IT AND IT WILL WORK,", 100, 200);
  text("OTHERWISE IT ISA PROBLEM WITH YOUR HARDWARE", 100, 235);
  text("OR YOUR PROGRAMMING.", 100, 280);
}
}

void serialcheck()
{
  delay(12);
  if (port.available() >= 1) {
    serialt = true;
  }
   else {
     serialt = false;
}
}

void update(int x, int y)
{
  if(locked == false) {
  //  circle1.update();
  //  circle2.update();
    circle3.update();
   // rect1.update();
  //  rect2.update();
  }
  else {
    locked = false;
  }

  if(mousePressed) {
    if(circle1.pressed()) {
      currentcolor = circle1.basecolor;
    }
    else if(circle2.pressed()) {
      currentcolor = circle2.basecolor;
    }
    else if(circle3.pressed()) {
      if (Herr == true) {
        Herr = false;
      }
            else {
        Herr = true;
      }
    }
  }
}


class Button
{
  int x, y;
  int size;
  color basecolor, highlightcolor;
  color currentcolor;
  boolean over = false;
  boolean pressed = false;  

  void update()
  {
    if(over()) {
      currentcolor = highlightcolor;
    }
    else {
      currentcolor = basecolor;
    }
  }

  boolean pressed()
  {
    if(over) {
      locked = true;
      return true;
    }
    else {
      locked = false;
      return false;
    }   
  }

  boolean over()
  {
    return true;
  }

  boolean overRect(int x, int y, int width, int height)
  {
    if (mouseX >= x && mouseX <= x+width &&
      mouseY >= y && mouseY <= y+height) {
      return true;
    }
    else {
      return false;
    }
  }

  boolean overCircle(int x, int y, int diameter)
  {
    float disX = x - mouseX;
    float disY = y - mouseY;
    if(sqrt(sq(disX) + sq(disY)) < diameter/2 ) {
      return true;
    }
    else {
      return false;
    }
  }

}

class CircleButton extends Button
{
  CircleButton(int ix, int iy, int isize, color icolor, color ihighlight)
  {
    x = ix;
    y = iy;
    size = isize;
    basecolor = icolor;
    highlightcolor = ihighlight;
    currentcolor = basecolor;
  }

  boolean over()
  {
    if( overCircle(x, y, size) ) {
      over = true;
      return true;
    }
    else {
      over = false;
      return false;
    }
  }

  void display()
  {
    stroke(255);
    fill(currentcolor);
    ellipse(x, y, size, size);
  }
}

class RectButton extends Button
{
  RectButton(int ix, int iy, int isize, color icolor, color ihighlight)
  {
    x = ix;
    y = iy;
    size = isize;
    basecolor = icolor;
    highlightcolor = ihighlight;
    currentcolor = basecolor;
  }

  boolean over()
  {
    if( overRect(x, y, size, size) ) {
      over = true;
      return true;
    }
    else {
      over = false;
      return false;
    }
  }

  void display()
  {
    stroke(255);
    fill(currentcolor);
    rect(x, y, size, size);
  }
}

Step 4: Programming Arduino

Super short code, just to make it simple. Just copy paste this code.

#define ANALOG_IN 0

void setup() {
  Serial.begin(9600);
}

void loop() {
  int val = analogRead(ANALOG_IN);
  Serial.print( 0xff, BYTE);
  Serial.print( (val >> 8) & 0xff, BYTE);
  Serial.print( val & 0xff, BYTE);
}

Step 5: Running the Code.

Since I have made this as simple as possible, all you have to do now is go to the page you pasted my processing code and press Sketch then press Run. it should pop up eventually and it will be a blue screen with a grey button, click the button to turn it on (WARNING: THE BUTTON IS SOMETIMES GLITCHES) after that you should have a working Oscope. If the error message pops up then you probably have a hardware problem, or possibly you didn't program the Arduino, or you might not have it connected.



                                                                                                                    ENJOY!                                                                                                                                                                                                    


                             CREATOR: simonfrfr BUILDER: simonfrfr Photographer: simonfrfr PROGRAMMER: simonfrfr                                                                               
<p>Just made it! Quite cool and easy!</p><p>the arduino loop() I used for Arduino IDE 1.5.5:</p><p>void loop() {</p><p> int val = analogRead(ANALOG_IN);</p><p> Serial.write( 0xff);</p><p> Serial.write((val &gt;&gt; 8) &amp; 0xff);</p><p> Serial.write((val) &amp; 0xff);</p><p>}</p>
<p>Oh, I am using Linux Ubuntu 12.04 and I exported the Processing sketch to a standalone program. Everything working as intended!</p><p>I maybe make an update of the processing code sometime, to include voltage indications. Any help is welcome!</p>
Please post comments so that I can help you or so I can see how it worked out for you. Thanks.
<p>it dosen't work ?</p>
<p>You put a Processing Sketch (A different program than Arduino) in the Arduino IDE. to download the software for that program, visit: processing.org</p>
<p>What is the voltage range this project can read? Can it read negative as well?</p>
<p>hey it gives an error message saying &quot;Could not load font Zigguart-HTF-Black-32.vlw&quot; even if i have placed it in the data folder of my sketch.......please tell me how to fix it</p>
<p>Hi, I hope that with 1 year time problem of error &quot;Could not load font Zigguart-HTF-Black-32.vlw&quot; is solved? </p><p>I'm using Mac with OSX 10.10. and have the same problem. </p><p>Very nice project.</p><p>Please kindly help, </p><p>toksaj@gmail.com</p>
<p>it doens't work on uno rev3 with 1.64 soft</p>
<p>excellent job! but I have some questions to ask you.What's are circle1,circle2 and circle3 used for ? I can see you only displays circle3 so is it the button?,however,when i tried to display circle1 and circle2.I found no any other thing appeared and when i pressed the button,the oscolloscope didn't show the wave</p>
<p>this is a very interesting project and you did a great job, the only thing that could make it better was a technical explanation of how o'scopes work for the people that do not understand how they do their little magic, and some more comments within the code. i think you did a great job though, and its quite ingenious for a 14yo, though your 16 now, so I'm sure you've moved on to new exciting things and don't care about this any longer, which is understandable.</p>
<p>The way an Oscilloscope works is actually an internal ADC's (Analog to Digital Converter) output is used to determine the voltage. The reading works like this: Voltage over Time. Which is how the program on Processing works. </p>
This looks fantastic and I'm really excited for the next version of this you've mentioned you're working on - can't wait! I'm a hobbyist working on mostly analogue synth electronics, so I don't need a $300 (second hand) o'scope. It's a good excuse for me to clutter my house more and get into Arduino too!
Sorry the connection was lost....... But I did everything right. Don't Know what I'm doing wrong :(
Do you have windows?
Your code wont work for me pleas fix it :(
Explain what doesn't work please.
This oscilloscope is far from being perfect, but the beauty - not to say the ingenuity - is in its simplicity. <br>(I had some small electronical problems and was thinking about buying an oscilloscope just to find the bug. With the help of this instructable it was very easy to find the bug.) <br>The casing for my 'ArduScope' is an empty matchbox and it will be a permanent help in my toolbox. <br>Thank you!
Thanks!
this code isnt compatible with arduino 1.0, it would be great if you can update it. <br>&quot;As of Arduino 1.0, the 'BYTE' keyword is no longer supported. <br>Please use Serial.write() instead.&quot; <br>this is the error <br>
Its funny, I am making a second version of this with my Newton Labs group.
actually, it is, the command was changed to &quot;byte()&quot;
You're only 14 and built this? You need a good kick up the butt, hard enough to knock you up a couple of grades at school. <br> <br>Like others, I think your headline photo is a little deceptive. Not being familiar with u.s. products, and certainly not searching hard for an Oscilloscope when I shelled out money for a good one, the headline photo suggests that you have built an entirely stand-alone unit (hack out of a laptop?) with so many finger-adjustable analog features that, if true, would have been a fantastic (as in 'fantasy') result. <br> <br>Keep up the good work.
Thank-you so much. :D I love the picture of your LCARS, its funny because I love Star Trek. :D
Nice job. This should let you see signals when a voltmeter just isn't enough. And it gives you plenty of opportunities for upgrade projects. For example, you could add some input protection so you don't damage your Arduino if you measure a voltage thats a little too high (I've included a sketch as an example). <br> <br>You might want to include a photo of the display screen or a screen shot from your video in the instructable, perhaps even as the main photo. That might help people understand your project better. Keep up the good work.
Thanks I will take that into consideration, but I am building a newer version of this for a display that you can take with you anywhere :D
I second this! Would be great if you showed your user interface. Maybe a video demo of all the things it can do. Thanks for posting this instructable!
Respectfully while I wouldn't expect this to perform anywhere near the commercial unit in the lead photo, there's is nothing in this instructable that compels me to consider duplicating the project. Nearly impossible to tell if you have designed a serviceable oscilloscope. Good luck in the contest.
Well It is not supposed to but that is a picture of an Oscope right? Plus I will be adding more later as another one to perform more than basic zoom and plot, I will add signal generators into it and more, PS thanks for making a comment.

About This Instructable

58,870views

75favorites

License:

Bio: Hey YOU! Yeah, I'm talking to you who is reading this. Send me ideas for instructables, like things that you are wondering how to ... More »
More by simonfrfr:DIY Spectrometer) Explore the Unknown -> Zombie Attack! Easy to build! Newton Labs Projects Arduino Guide (2012) 
Add instructable to: