Here is the Jbasic Code.
Good luck
'Basic Serial Port Send and Receive with Voice Output.
'You need to start a " Text to Speach " clip board program ( i.e Simple TTS reader ),
'if you want to hear the Time / Date spoken.
'Written by Brian Archer.
[Start]
print "At start"
'This sets the foreground and background screen colours
BackgroundColor$ = "blue"
ForegroundColor$ = "yellow"
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[Buttons]
'Setting up the Push Button positions and control procedures.
button #dialog2.accept, "Tell me the Time", [Timerequest], UL, 10, 55 ' i.e. the box you click etc.
button #dialog2.accept, "Tell me the Date", [Daterequest], UL, 10, 85 ' i.e. the box you click etc.
button #dialog2.accept, "Quit", [Quit], UL, 10, 115 ' i.e. the box you click etc.
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
UpperLeftX = 300
UpperLeftY = 2 'this sets the hight of the window from the top of the screen.
WindowWidth = 300 'this set the width dimension of the window.
WindowHeight = 200 'this set the hight dimension of the window.
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'open "Buttons" for dialog as #dialog2 'This is the screen push buttons
open "Arduino to Jbasic Test Program" for dialog as #dialog2 ' name of the window, that appears at the top of the blue screen.
print #dialog2, "font courier_new 8 italic" ' font type.
print #dialog2, "trapclose [Quit]" ' end your text command.
wait
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'This is the serial port output command for "Tell me the Time".
'Remember to change the com port number to the com port of your computer
[Timerequest]
close #dialog2
print "Sending Serial Command Tell Me The Time"
print ""
Com = 16384
'XXXXX CHECK OR CHANGE COM1 TO YOUR COM PORT NUMBER XXXXX.
open "com1:4800,n,8,1,ds0,cs0,rs" for random as #commHandle
for I = 1 to 10000
next I
print #commHandle, "time"; ' Serial Coms Port output command.
for I = 1 to 10000
next I
close #commHandle
print "done"
print ""
for I = 1 to 80000
next I
goto [Serialreply]
end
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'This is the serial port output command for "Tell me the Date".
'Remember to change the com port number to the com port of your computer
[Daterequest]
close #dialog2
print "Sending Serial Command Tell me the date"
print ""
Com = 16384
'XXXXX CHECK OR CHANGE COM1 TO YOUR COM PORT NUMBER XXXXX.
open "com1:4800,n,8,1,ds0,cs0,rs" for random as #commHandle
for I = 1 to 10000
next I
print #commHandle, "date"; ' Serial Coms Port output command.
for I = 1 to 10000
next I
close #commHandle
print "done"
print ""
for I = 1 to 80000
next I
goto [Serialreply]
end
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[Serialreply]
print "At Serial Reply"
print ""
for I = 1 to 2000
next I
Com = 16384
open "com1:4800,n,8,1,ds0,cs0,rs" for random as #commHandle ' this is waiting for the arduino to send data.
for I = 1 to 300000 'You need this timer to allow the port to read the multible times, you may have to adjust
'this for slow computers, i.e. 800000
next I
while numBytes=0 ' This bit loops and waits for a response from Arduino
numBytes = lof(#commHandle)
wend
dataRead$ = input$(#commHandle, lof(#commHandle))
print dataRead$
print ""
close #commHandle
print "Left Serial Reply"
print ""
if dataRead$ = "00000001" goto [Time]
if dataRead$ = "00000002" goto [Date] else [Serialreply] ' i.e. this loops back and waits for a Serial Coms reply
end
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[Time]
print "You are at Time"
print " "
open "Time" for text as #1 'This sets up data to be copied to the clip board.
print #1, "the time is "
print #1, time$()
gosub [PrintToSpeak] ' this allows the computer to speak.
print time$() ' this prints the Time to the screen.
print ""
print "You have left Time"
print ""
goto [Start]
end
''xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[Date]
print "You are at Date"
print " "
open "Date" for text as #1 'This sets up data to be copied to the clip board.
print #1, "The date is "
print #1, date$()
gosub [PrintToSpeak]
print date$() ' this prints the Date to the screen.
print ""
print "You have left Date"
print ""
goto [Start]
end
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[PrintToSpeak]
print "at [PrintToSpeak]"
print ""
print #1, "!selectall" ; ' this part prints to the clip board, thus allowing the Text to Speach program to work.
print #1, "!copy" ;
print #1, "!paste" ;
close #1
open "Clear Print to Speak" for text as #1 ' this clears the clip board ready for the next message.
print #1,""
close #1
print "left [PrintToSpeak]"
print ""
gosub [Timer1] ' this timer allows enough time for the computer to speak, you may have to adjust this.
print ""
return
end
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[Timer1]
print "at [Timer1]"
for I = 1 to 100000 ' this timer allows enough time for the computer to speak, you may have to adjust this.
next I
print ""
print "left [Timer1]"
print""
return
end
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[Quit]
print "At Quit"
print ""
close #dialog2
print "Program Stopped"
end
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'END OF PROGRAM
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx