Hi Rob (Robtillaart)
Many thanks for your reply.
Also Hi to anybody reading this forum.
I would like to show you another example of serial communication between Arduino and Jbasic.
If you got the first example to work, you may want to try this one.
This example is for serial communication (send and receive) between Arduino and Jbasic with voice output.
Please download both the Arduino and Jbasic code and install / run etc.
On the Arduino Text monitor you can see whats going on with the Arduino code.
To hear the voice you will need to download and run a clip board Text to Voice program ( i.e. Simple TTS reader ).
These are just example codes for you to try, I am not claimig they are the best way to do this, but I hope it gets people to experiment with Serial Communication, i.e. with analogue / digital inputs to your Arduino you can get a voice responce to your commands etc.
Just cut and paste the Arduino code below and read my next (reply for the Jbasic Code).
I would be interested to receive comments, on how you guys out there , get on etc.
//Arduino Code
//Serial communication Arduino to Jbasic
// Program created and written by Brian Archer
// No originality is claimed for this program, this example code is classed as public domain.
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#include <SoftwareSerial.h>
String readString = String(0);
// RS 232 / TTL connection.
SoftwareSerial mySerial(5,6); // Arduino board pin positions 5 = TXin, 6 = RXout This is the connection to and from the RS 232 / TTL board.
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void setup(){
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
// Setting the the serial ports baud rates
Serial.begin(57600); // this is the communication baud rate for the Arduino Text Monitor.
Serial.println("Start of Program");
Serial.println(" ");
delay (10);
mySerial.begin(4800); // this is the communication baud rate for the RS232 / TTL board, (Jbasic serial port generator).
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void loop() {
delay (1000); //Main loop delay, you can vary this time to suit your loop speed
Serial.println("Start of Loop");
Serial.println(" ");
delay(10);
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// readimg serial port
{
Serial.println("Reading serial");
Serial.println("");
while (mySerial.available()) {
delay(10);
if (mySerial.available() >0) {
char c = mySerial.read();
readString += c;}
}
if (readString.length() >0) {
delay(100);
}
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{
//Read option 1
if (readString == "time") {
delay (10);
Serial.println("LED On");
Serial.println(" ");
digitalWrite(13, HIGH); // sets the LED on
delay(500); // wait for a 4 seconds
Serial.println("LED Off");
Serial.println(" ");
digitalWrite(13, LOW); // sets the LED off
delay(500); // wait for 2 seconds
mySerial.print("00000001");
delay (1000);
// Just insert your own program here, instead of turning the LED on pin 13 on and off.
}
else
{
digitalWrite(13, LOW); // set the LED off
}
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{
//Read option 2
if (readString == "date") {
delay (10);
Serial.println("LED On");
Serial.println(" ");
digitalWrite(13, HIGH); // sets the LED on
delay(500); // wait for a 4 seconds
Serial.println("LED Off");
Serial.println(" ");
digitalWrite(13, LOW); // sets the LED off
delay(500); // wait for 2 seconds
mySerial.print("00000002");
delay (1000);
// Just insert your own program here, instead of turning the LED on pin 13 on and off.
}
else
{
digitalWrite(13, LOW); // set the LED off
}
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{
// Clear buffer, this is a must when using a loop.
readString="";
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{
// End of loop
Serial.println("End of Loop");
Serial.println(" ");
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
} // This is linked to the void loop () {
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// END of PROGRAM
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx