Red LED and two buttons

stari

Active Member
Licensed User
Longtime User
Hi ,i program Arduino in C . Arduino has low memory, i love Erel's work but i think that programmig Arduino in basic language reduces the available "program memory"
Hi, i programm NetDuino in basic, with VisualStudio. No problems at all.
 

stari

Active Member
Licensed User
Longtime User
This is a preliminary test of a possible new development tool for Arduino devices (B4R).
This is, i think, without .NET ? I programm NetDuino (similar to Arduino), with basic, VisualStudio 2013, but i need to load MicroFramework.
 

max123

Well-Known Member
Licensed User
Longtime User
I use ESP8266 on Arduino IDE, this is very low cost (3-6$) amazing chip for ioT with WiFi b/g/n and 32 bit microcontroller that work @ 80Mhz and @ 160Mhz clock and mounted on very small boards.

It is supported on Arduino IDE using 3rd party boards (Boards Manager)

Maybe in future it is possible to add this extension to B4R ? :D

I like Erel idea because Arduino IDE is not very good to use for complex programs, i recently writed a library (around 1600 lines of code) and is not very good to use.... it don't show variables and Functions, to search variables i need to search text in the code, then more important it don't has AutoComplete and no debug.

So many thanks for this....;)
 
Last edited:

fixit30

Active Member
Licensed User
Longtime User
Can I pay anything nonetheless? :)

I agree. Sometimes I think @Erel is far too generous. I would rather pay a small fee similar to B4A for an excellent product than expect it for free. We need to pay somehow for the significant efforts for the development. Otherwise development will take less priority over other B4X products. (No disrespect to Erel)
 

mterveen

Member
Licensed User
Longtime User
i'm in for a few bucks also. this would be a fantastic product. currently i have an app in windows (VB.net) and b4a (basic lookalike), interfacing via bluetooth to an arduino mega (c/c++). trying to jump back and forth between programming syntax/nuances can be frustrating. obviously due to the limitations of the arduino the product would have to be incredibly memory efficient. how would the debugger work? and the uploader for the sketch? i assume you would use the arduino libraries (e.g. wire, sdfat, spi, serial, etc)?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Sometimes I think @Erel is far too generous
I see it in a different way. I want the B4X suite to be as popular as possible. B4R as a free tool will help with encouraging developers to use B4X tools for development.
Remember that B4J is also free and it is being actively developed.

how would the debugger work?
There will be no debugger in the first version (note that there is also no debugger in Arduino IDE).
incredibly memory efficient
This is true.

and the uploader for the sketch?
It uses Arduino IDE command line tool to upload the project. This is similar to how B4A uses Android SDK to upload the APK (in USB debug mode).
 

Toley

Active Member
Licensed User
Longtime User
Sometimes I think @Erel is far too generous.
Maybe a donationware could be an idea. The same can apply to B4J.

I have another question. Is it done with B4J? This would be a very good promotion for B4J. BTW I think showing what can be done with the software is the best way to promote it!
 

Toley

Active Member
Licensed User
Longtime User
What do you mean with 'it' ? The IDE is the same IDE as the other products.
Yes I mean the IDE. But I still believe the best way to promote your products is to show complete and real applications build with it.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

B4R code:
B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Dim eth As Ethernet
   Dim sock As EthernetSocket
   Dim Astream As AsyncStreams
   Dim pins(3) As Pin
   Dim btn As Pin
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Dim pinNumbers() As Byte = Array As Byte(pins(0).A0, pins(0).A1, pins(0).A2)
   For i = 0 To pins.Length - 1
     pins(i).Initialize(pinNumbers(i), pins(i).MODE_OUTPUT)
     pins(i).DigitalWrite(True)
   Next
   btn.Initialize(btn.A3, btn.MODE_INPUT_PULLUP)
   btn.AddListener("Btn_StateChanged")
   Log("Trying to connect...")
   If eth.InitializeDHCP(Array As Byte(0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED)) = False Then
     Log("Error getting ip address.")
   Else
     If sock.ConnectIP(Array As Byte(192, 168, 0, 8), 51042) = False Then
       Log("Error connecting")
     Else
       Log("Connected")
       Astream.Initialize(sock.Stream, "Astream_NewData", "Astream_Error")
     End If
   End If
End Sub

Sub Btn_StateChanged (State As Boolean)
   Dim b(1) As Byte
   If State Then b(0) = 1 Else b(0) = 0
   Astream.Write(b)
End Sub

Sub Astream_NewData (Buffer() As Byte)
   Dim bc As ByteConverter
   Log("NewData: ", bc.HexFromBytes(Buffer))
   For i = 0 To Buffer.Length - 1 Step 2
     Dim b As Boolean
     If Buffer(i + 1) = 1 Then b = True Else b = False
     pins(Buffer(i)).DigitalWrite(b)
   Next
End Sub

Sub Astream_Error
   Log("Error")
End Sub

B4A code:
B4X:
Sub Process_Globals
   Private server As ServerSocket
   Private astream As AsyncStreams
End Sub

Sub Globals
   Private Switch1 As Switch
   Private Switch2 As Switch
   Private Switch3 As Switch
   Private Switches As List
   Private lblButton As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   Switches = Array(Switch1, Switch2, Switch3)
   If FirstTime Then
     server.Initialize(51042, "server")
     server.Listen
     Log($"My ip: ${server.GetMyWifiIP}"$)
   End If
End Sub

Private Sub Server_NewConnection (Successful As Boolean, NewSocket As Socket)
   Log($"NewConnection: ${Successful}"$)
   If Successful Then
     If astream.IsInitialized Then astream.Close
     astream.Initialize(NewSocket.InputStream, NewSocket.OutputStream, "astream")
     For Each s As Switch In Switches
       s.Checked = True
     Next
   End If
   server.Listen
End Sub

Sub Switch_CheckedChange(Checked As Boolean)
   Dim i As Int = Switches.IndexOf(Sender)
   If astream.IsInitialized Then
     Dim b As Byte
     If Checked Then b = 1 Else b = 0
     astream.Write(Array As Byte(i, b))
   End If
End Sub

Private Sub AStream_NewData (Buffer() As Byte)
   If Buffer(0) = 1 Then lblButton.Text = "Button Up" Else lblButton.Text = "Button Down"
End Sub

The Arduino board is an Uno with Ethernet shield.
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Great Erel , B4X family is still growing .
Do you have other plans for other platforms ? :)
 

Toley

Active Member
Licensed User
Longtime User
Good example Erel, what board is it? A UNO with an ethernet sheild? Do you plan to support all the native Arduino libraries?

I must admit the B4R code is really simple. Probably simpler than doing the same in Arduino C language.
 
Top