Pages: [1]   Go Down
Author Topic: Serial Communication using Arduino and Jbasic  (Read 2778 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would like to pass on to others, some of the work I have been developing using the Arduino Uno processor board and J basic.

This is intended to show how to use Serial port communication to and from a simple Basic program, without having to learn the more advanced C# type programs.

I realised coupling the two types of programs, you can develop some very interesting projects.

J basic is a free easy Basic program ( i.e. the free version of liberty basic ), this can be found and downloaded from the internet.

My interest is in AI and I have been developing a robot called Loopy , ( hence my Avatar photo ).
Loopy can do many exciting things like Talk, Remember Data, respond to room stimuli etc.

All this can be achieved by using Serial Communication between J basic and Arduino.
To get this working you will need a Arduino Uno  (other boards may also work?).
An  RS 232 to TTL converter.
If you are using a USB port on the PC you will also need a USB to RS232 converter
Some wires to link the RS 232 / TTL converter to the Arduino Uno board.
A Cable to connect the RS 232 / TTL converter to the PC,  NOT a NULL type cable!.
A power source for the Arduino Uno.


(1)   Connect all wires and cables,  note I am using Arduino  pins 5 = TX in  and 6 = Rx out
(2)    Download my Arduino Sketch “Arduino_Jbasic”.
(3)   Download my Jbasic test program.
(4)   Open up the Arduino Serial port  monitor ( 57600 baud rate ), so you can see what is happening.
(5)   Download Jbasic from the internet, and open and run my program.
(6)   Click on the “Test 1” button.
(7)   You should see the LED ( pin 13 )on the Arduino board flash on and off twice.

Here is a photo of the first test setup, more examples from my project  /  Serial Communication will be supplied in due course if there is enough interest, good luck.

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 == "test1") {
  delay (10);
   
   
  Serial.println("LED On");
  Serial.println(" ");
  digitalWrite(13, HIGH);   // sets the LED on
  delay(4000);              // wait for a 4 seconds
 
 
  Serial.println("LED Off");
  Serial.println(" ");
  digitalWrite(13, LOW);    // sets the LED off
  delay(2000);              // wait for 2 seconds
 
  Serial.println("LED On");
  Serial.println(" ");
  digitalWrite(13, HIGH);   // sets the LED on
  delay(4000);              // wait for a 4 seconds
 
  Serial.println("LED Off");
  Serial.println(" ");
  digitalWrite(13, LOW);    // sets the LED off
  delay(2000);              // wait for 2 seconds
 
  // 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

Code:
Jbasic Code

'Basic Serial Port Generator.
'Written by Brian Archer
'No originality is claimed for this program

'START

print " At start "

'This sets the foreground and background screen colours
BackgroundColor$ =  "blue"
ForegroundColor$ = "yellow"

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

'Setting up the Push Button positions and control procedures.

button #dialog2.accept, "Test 1", [Test1], UL, 10, 55 ' i.e. the box you click etc.

button #dialog2.accept, "Quit",   [Quit],  UL, 10, 85 ' 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 "Element 14 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

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

'This is the serial port output command.
'Remember to change the com port number to the com port of your computer

[Test1]

print "Sending Serial Command Test 1"
print ""

Com = 16384

'XXXXX  CHANGE COM5 TO YOUR COM PORT NUMBER XXXXX.

open "com5:4800,n,8,1,ds0,cs0,rs" for random as #commHandle

for I = 1 to 10000
next I

print #commHandle, "test1";

for I = 1 to 10000
    next I
close #commHandle

print "done"
print ""

for I = 1 to 80000
next I

wait
end

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

[Quit]

print "At Quit"
print ""

close #dialog2

print "Program Stopped"

end

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'END OF PROGRAM
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx




* Arduino_Jbasic.ino (2.86 KB - downloaded 22 times.)

* DSCF0005.JPG (140.47 KB, 1280x960 - viewed 59 times.)
* Jbasic_Element14_Test1.bas (2.25 KB - downloaded 31 times.)
« Last Edit: November 10, 2012, 01:59:49 pm by Loopy » Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 85
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Loopy keep up the good work & keep posting.
I'm from a Liberty Basic background and somewhat still a Arduino virgin still waiting for my first hardware to be delivered.
I'm wanting to produce a GUI and my first thoughts were using Liberty Basic but after looking at some of the YouTube posts are now thinking Visual Basic 2010 may be the best way to go although it has a greater learning curve. 
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Rbright

Many thanks for the reply and best of luck with the Arduino hardware and Visual basic programming.

When you have received your Arduino board maybe you would like to try out my programs.
I would be very interested if other people can get these to work, I have tried to explain it so that any newcomers to Arduino and Jbasic
can get it up and running with the minimum of trouble.

A couple of notes, for other readers.

(1) You must check or change the Com port number on the Jbasic program to the working Com port number you are going to use,
     it is best to get the USB / RS 232 to TTL converter working before connecting it to the Arduino ( pins 5 and 6),  one way to do this
     is to run Hyperterminal and check the com port numbers available then pick the one associated to your USB /RS 232 to TTL converter.
     You should see an LED flash when sending on the Hyperterminal.

(2) The way I have described the (Arduino) TTL TX and RX pin locations may seem a little strange, but what I am trying to ensure is that
     The TX output from whatever USB / RS232 / to TTL converter you are using must go to pin 5 on the Arduino Uno board.
     My RS 232 / TTL converter has incorrect TX and RX labels (i.e. the wrong way round).

    Best of luck guys, please send in your comments, will publish some more examples of My Serial Communication ASAP
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 224
Posts: 13917
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for sharing,

Can you post your favorite links to Jbasic ?



Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 1
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


Code:
//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


« Last Edit: November 10, 2012, 01:40:23 pm by Loopy » Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Code:
[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
« Last Edit: November 10, 2012, 01:38:55 pm by Loopy » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 224
Posts: 13917
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

please modify your post , select the code part and press the # button. will make it look so much more readable.

Works also for Jbasic code smiley
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 1
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Rob (RobTillaart)

Many thanks for the tip #, I am new to this forum and I did not know how to do this procedure, yes it makes it so much better to read.
I also modified my first post, so people can read the codes in the same manner.

With my 2nd example,one thing you guys out there might like to know, is that if you have Windows Vista "speech recognition", you can talk to the Arduino / Jbasic program, i.e. Get both programs up and running place the curser on the Jbasic blue screen and say "Click tell me the time", you should here the computer respond with the time etc.
This is how I communicate with my robot Loopy, it sometimes feels a little spooky when the robot responds, especially when you forget it is still listening.

I would be intersted to know if anybody has tried these codes out, and have successfully modified them to your needs.

If I can help you with this topic please ask.

Cheers Loopy
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9701
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Below is some justbasic code I used to make an application for using a joystick to pan/tilt a two servo cam setup in ~2005. The servo controller was not an arduino, but the code basics should be useable with an arduino

Code:
open "joystick demo" for graphics as #joy
OPEN "com3:9600,N,8,1,CD0,CS0,DS0,OP0" FOR OUTPUT AS #2
#joy "down" 'put the pen down
#joy "trapclose [quit]"
timer 10, [readStick] 'every ten ms read the stick
wait

[readStick]
    scan
    readjoystick 1 'either 1 or 2
    #joy "place 50 50"
    #joy "\Reading X = "; Joy1x
    #joy "\Reading Y = "; Joy1y
    #joy "\Reading Z = "; Joy1z 'throttle slide
    #joy "\Reading X = "; (Joy1x - 1200)/195
    #joy "\Reading Y = "; (Joy1y - 1200)/195
    x = (Joy1x - 1200)/195
    y = (Joy1y - 1200)/195
    x1 = int(x)
    y1 = int(y)
    #joy "\Reading X1 = "; x1;"  "
    #joy "\Reading Y1 = "; y1;"  "
    #joy "\Reading jb1 = "; Joy1button1;"  "
    #joy "\Reading jb2 = "; Joy1button2;"  "

    if Joy1button1 = 1 then
        PRINT #2, CHR$(00); CHR$(128); CHR$(x1);
        PRINT #2, CHR$(01); CHR$(128); CHR$(y1);
    end if

     if Joy1button2 = 2 then
        PRINT #2, CHR$(00); CHR$(128); CHR$(x1);
        PRINT #2, CHR$(01); CHR$(128); CHR$(y1);
    end if

    wait

[quit]
    CLOSE #2
    close #joy
    end
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Jr. Member
**
Karma: 1
Posts: 85
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Loopy keep the posts coming - I'll following them while waiting for my first couple of Arduinos to be delivered.

As I mentioned before I'm keen to see a GUI to interface with Arduino and I see 3 options:

* go with Just Basic / Liberty Basic but I'm thinking processor speed may be a problem especially if I want some animated graphics
* go with Processor the application of choice for a lot of arduino posts - but a new system to learn although code looks C based like & is related to arduino
* go with freebee Visual Basic 2010 Express and use a brilliant find for GUI being advancedHMI - refer to posts at this forum at following link
http://arduino.cc/forum/index.php/topic,131915.0.html
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Zoomcat

Many thanks for the code, may come in useful when my Robot become mobile.

And many thanks to Rbright for the hyperlink etc, again good look in choosing your Computer software.

All of my work so far has been creating this robot (loopy) and only the basic human type refex actions,
and voice controlled servo actions are performed by the Arduino Uno's, most of the brain functions are performed by jbasic.
i.e. speach, asking for and remembering data, telling jokes, and responding to voice commands,
and as such, I think most of this would only be of interest to other robotic builders and not for this Arduino forum.

But if I can think of any more basic Arduino code that would be useful then I will post it.

I would be interested if anyone can create similar perfomance by using an Arduino Uno and a higher language like C#.

Cheers Guys
Logged

Pages: [1]   Go Up
Jump to: