question

DietrichEdgar-2311 avatar image
0 Votes"
DietrichEdgar-2311 asked Scout-1150 answered

How can you control individual pins on an Arduino with Small Basic via USB?

Hello, I would like to control individual pins on an Arduino Mega via USB with Small Basic. How do I have to proceed? Is there maybe an SB extension?

small-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Scout-1150 avatar image
0 Votes"
Scout-1150 answered

Hi Edgar,

here is an interesting link:

tinkering-arduino-and-small-basic

I'm assuming USB is simulating a COM port and would do the following:
1) Find out which COM port is used and which commands are necessary to control the LED (forum, IDE, manuals, ...)
2) Try to control the board manually with these commands with a terminal emulation (Teraterm, Hyperterminal, ...)
3) Now everything can be automated with SmallBasic and the litdev-extension LDCOMMPort and brought into a nice GUI.

Example of simple polling of the Kettler exercise bike AX1:

 GraphicsWindow.Title = "MS SmallBasic Ergograph Kettler AX1"
 GraphicsWindow.BackgroundColor = "#30C8CF"
 GraphicsWindow.Height = 600
 GraphicsWindow.Width = 800
 GraphicsWindow.BrushColor = "Black"
    
 INFO_Box=Controls.AddTextBox(7,570)
 Controls.SetSize(INFO_Box,400,20)
 Count_Box=Controls.AddTextBox(407,570)
 Controls.SetSize(Count_Box,70,20)
 Puls_Box=Controls.AddTextBox(7,10)
 Controls.SetSize(Puls_Box,40,22)
 Drehzahl_Box=Controls.AddTextBox(7,40)
 Controls.SetSize(Drehzahl_Box,40,22)
 kmh_Box=Controls.AddTextBox(7,70)
 Controls.SetSize(kmh_Box,40,22)
 km_Box=Controls.AddTextBox(7,100)
 Controls.SetSize(km_Box,40,22)
 Watt_Box=Controls.AddTextBox(755,40)
 Controls.SetSize(Watt_Box,40,22)
 kJoule_Box=Controls.AddTextBox(7,130)
 Controls.SetSize(kJoule_Box,40,22)
 runtime_Box=Controls.AddTextBox(750,10)
 Controls.SetSize(runtime_Box,45,22)
 iWatt_Box=Controls.AddTextBox(755,63)
 Controls.SetSize(iWatt_Box,40,22)
    
 LDCommPort.OpenPort("COM1",9600)
 Program.Delay(50)
 For i=1 To 10000
   LDCommPort.TXString("PW")
   LDCommPort.TXByte(13) 'Send carriage return'
   LDCommPort.TXByte(10) 'Send linefeed'
   Program.Delay(400)
   ST = LDCommPort.RXAll()
   Controls.SetTextBoxText(INFO_Box,ST)
   Controls.SetTextBoxText(Count_Box,i)
   'TextWindow.Write(i+":")'
   'TextWindow.Write(CommPort.RXAll())'
   Program.Delay(100)
   Puls = Text.GetSubText(ST,1,3)
   Controls.SetTextBoxText(Puls_Box,Puls)
   Drehzahl = Text.GetSubText(ST,5,3)
   Controls.SetTextBoxText(Drehzahl_Box,Drehzahl)
   kmh = Text.GetSubText(ST,9,3)
   Controls.SetTextBoxText(kmh_Box,kmh/10)
   km  = Text.GetSubText(ST,13,3)
   Controls.SetTextBoxText(km_Box,km/10)
   Watt  = Text.GetSubText(ST,17,3)
   Controls.SetTextBoxText(Watt_Box,Watt)
   kJoule  = Text.GetSubText(ST,21,4)
   Controls.SetTextBoxText(kJoule_Box,kJoule)
   runtime  = Text.GetSubText(ST,26,5)
   Controls.SetTextBoxText(runtime_Box,runtime)
   iWatt  = Text.GetSubText(ST,32,3)
   Controls.SetTextBoxText(iWatt_Box,iWatt)
 EndFor
 LDCommPort.ClosePort()




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.