having a oscilloscope has been a dream for me since i started leaning electronics, because i can't afford buying an Oscilloscope( i never buy second hand electrical equipment ). Therefore i decided to solve my problem by myself, However i kinda failed.
The Arduino Oscilloscope has many problems such as its range ( ~ 1Khz :) ) and its scale ( there is no scale on the screen). the input also must be between 0 to 5 volt which is not a problem ( it can be increased by voltage dividers or using transistor). After all there are the Code for arduino and visual basic .... have some fun
**********************************Aurduino**************************
int incomingByte = 0;
const int analogInPin = 0;
int sensorValue = 0; // value read from the pot
void setup()
{
Serial.begin(115200);
pinMode(13,OUTPUT);
}
void loop()
{
sensorValue = analogRead(analogInPin);
Serial.println(sensorValue);
incomingByte=0;
delay(1);
}
NOTE: if u erase the delay, the computer will be left behind the data. Therefore the screen will be 20 sec behind what is actually happen .
*************************************Visual basic**************************
********* 3 text boxes and and a bottom are needed *****************
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
sp1.PortName = TextBox1.Text
sp1.Open()
Dim myPen As Pen = New Pen(Color.GreenYellow, 5)
sp1.Write(1)
Dim i As Integer
Dim u As Decimal
Dim x As Decimal
Dim z As Integer
Dim x1 As Decimal
Dim voltager As Integer
Dim timerange As Integer
Dim timerangex As Integer
voltager = Val(TextBox2.Text)
timerange = Val(TextBox3.Text)
Dim a As String
Dim n As Single
n = 0
Me.CreateGraphics.Clear(Color.Black)
Do
n = n + 1
If n = (800 / timerange) Then
n = 0
Me.CreateGraphics.Clear(Color.Black)
End If
a = sp1.ReadLine
z = Val(a)
x = 5 / 1024 * z
u = (5 * voltager)
x = x * voltager
x = u - x
Me.CreateGraphics.DrawLine(myPen, timerange * n, x1 - 1, timerange * n, x)
x1 = x
Loop
sp1.Close()
End Sub
End Class
*******************************************************
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment