LoginSignup
0
0

More than 5 years have passed since last update.

smallbasicでlogicanalyzer

Posted at

概要

 smallbasicでarduino unoを使って、logicanalyzerを作った。

写真

logic.JPG

サンプルコード1

x = 0
y = 0
yCenter = 300
Setup()
class1.OpenPort("COM5", 9600)
Loop:
  a = Class1.RXByte()
  x = x + 2
  If x > 800 Then
    x = 0
  endif
  If a - 128 < 0 then
    y = 220
  Else
    y = 200
    a = a - 128 
  endif
  If a - 64 < 0 then
    y = 250
  Else
    y = 230
    a = a - 64 
  endif
  If a - 32 < 0 then
    y = 280
  Else
    y = 260
    a = a - 32 
  endif
  If a - 16 < 0 then
    y = 310
  Else
    y = 290
    a = a - 16
  endif
  If a - 8 < 0 then
    y = 340
  Else
    y = 320
    a = a - 8 
  endif
  Shapes.Move(Dot3[x], x, y)
  If a - 4 < 0 then
    y = 370
  Else
    y = 350
    a = a - 4 
  EndIf
  Shapes.Move(Dot2[x], x, y)
  If a - 2 < 0 then
    y = 400
  Else
    y = 380
    a = a - 2 
  EndIf 
  Shapes.Move(Dot1[x], x, y)
   If a < 1 then
    y = 430
  Else
    y = 410
  EndIf 
  Shapes.Move(Dot0[x], x, y)
Goto Loop
Sub Setup
  GraphicsWindow.Width = 800
  GraphicsWindow.Height = 600
  GraphicsWindow.BackgroundColor = "Black"
  GraphicsWindow.Title = "logic analizer"
  GraphicsWindow.Show()
  For x = 0 To 800 Step 2
    GraphicsWindow.PenColor = "blue"
    GraphicsWindow.BrushColor = "blue"
    Dot0[x] = Shapes.AddEllipse(4, 4)
    Shapes.Move(Dot0[x], x, yCenter)
    GraphicsWindow.PenColor = "orange"
    GraphicsWindow.BrushColor = "orange"
    Dot1[x] = Shapes.AddEllipse(4, 4)
    Shapes.Move(Dot1[x], x, yCenter)
    GraphicsWindow.PenColor = "green"
    GraphicsWindow.BrushColor = "green"
    Dot2[x] = Shapes.AddEllipse(4, 4)
    Shapes.Move(Dot2[x], x, yCenter)
    GraphicsWindow.PenColor = "red"
    GraphicsWindow.BrushColor = "red"
    Dot3[x] = Shapes.AddEllipse(4, 4)
    Shapes.Move(Dot3[x], x, yCenter)
  EndFor
EndSub

サンプルコード2

void setup()
{
    Serial.begin(9600);
}
void loop()
{
    byte val = PINB;
    Serial.write(val);
}
0
0
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
0
0