B4R Question Can UART on Arduino Zero be used in a sketch?

tigrot

Well-Known Member
Licensed User
Hi everybody,
I have just started to use Arduino. I have already used Mega chips, but with Assembly.
Can UART on Mega 328 be used for normal activity(not debug) ?
This is not a question strictly related to B4R but I hope to find someone who can give more info's.

Thank you!

Best regards
Mauro
 

tigrot

Well-Known Member
Licensed User
Unfortunatelly it's not a MEGA328. I'll use a software simulated serial port. I have to receive a stream of LCD data/commands and display on a local LCD(to remote display). The cost of a micro/uno is really nothing.
Thank you Erel!

Mauro
 
Upvote 0

tigrot

Well-Known Member
Licensed User
I have tested a Arduino Pro Mini and since it has no USB/RS232 converter on board I was able to use UART at 115200 speed. That's ok for me. Only never use log() instruction...
I have written a simple echo sketch to test. It takes a char and echo back.
B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public Serial1 As Serial
   ' Public timer1 As Timer
    Public stream As AsyncStreams
End Sub

Private Sub AppStart
    'timer1.Initialize("timer1_Tick",1000)
    Serial1.Initialize(115200)
    stream.Initialize(Serial1.Stream,"stream_NewData","stream_Error")
    'timer1.Enabled=True
End Sub
Sub timer1_Tick
    'stream.Write(Array As Byte(0x41,0x42,0x43,0xA))
End Sub
Sub stream_NewData (Buffer() As Byte)
    stream.Write(Buffer)
End Sub
Sub stream_Error
    ' Log("Errore...")
End Sub
 
Upvote 0
Top