LoginSignup
2
2

More than 5 years have passed since last update.

smallbasicでosilloscope

Last updated at Posted at 2015-11-13

概要

 smallbasicでarduino unoを使ってosilloscopeを作った。

写真

osillo.JPG

サンプルコード1

yCenter = 300
y = 0
x = 0
SetupWindow()
InitVariables()
Class1.OpenPort("COM5", 9600)
Loop:
  Cur = Class1.RXByte()
  x = x + 1
  If x > 800 Then
    x = 0
  endif
  y = 400 - Cur
  Shapes.Move(Dot[x], x, y)
Goto Loop
Sub SetupWindow
  GraphicsWindow.Width = 800
  GraphicsWindow.Height = 600
  GraphicsWindow.BackgroundColor = "Black"
  GraphicsWindow.Title = "Osilloscope"
  GraphicsWindow.Show()
EndSub
Sub InitVariables
  GraphicsWindow.PenColor = "orange"
  GraphicsWindow.BrushColor = "orange"
  For x = 0 To 800 Step 2
    Dot[x] = Shapes.AddEllipse(4, 4)
    Shapes.Move(Dot[x], x, yCenter)
  EndFor
EndSub

サンプルコード2

void setup()
{
    Serial.begin(9600);
}
void loop()
{
    int val = analogRead(A0);
    Serial.write((val >> 8) & 0xff);
}
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2