controlling arduino with hyperterminal

Hi, im very new to the scene. Sorry to be a complete noob, but is there a way to control the arduinio from say hyperterminal?

Im looking to have a few lights, servos, fans and such controlable from the hyperterminal or equivilent terminal emulation programme. When i say controllable, it would mostly be on and off.

If anyone has any usefull link on how this could be achieved i would very much appreciate it.

Normally you do this by writing an arduino program that accepts serial information that does what you want to do. However there is a pre done piece of software that you could use:-
http://www.arduino.cc/playground/Interfacing/Firmata

There's something like Hyperterminal built into the Arduino IDE.

It uses the same serial link that you used to program the Ardy.

Put an LED on pin D13 (along with a resistor). Connect the other end of the LED-resistor circuit to ground. Then run the following....

//FrmSer1
//ver 28mar2010

boolean boFast= true;
int incomingByte=0;//sloppy: Should be local to loop function
int Out0=12;//pin LED will be attached to. Pull
// high to turn LED on... LED goes through resistor to gnd

void setup()
{
Serial.begin(9600);//For access to serial mon channel
pinMode(Out0,OUTPUT);
Serial.println("Enter s or f on serial terminal to make wink fast or slow");};

void loop()
{
if (Serial.available() > 0) {
            // read the incoming byte:
            incomingByte = Serial.read();

            // say what you got:
            Serial.print("I received: ");
            Serial.print(incomingByte, DEC);
        if (incomingByte==102) {boFast=true;
                Serial.println(", code for f, LED will wink fast.");};
        if (incomingByte==115) {boFast=false;
                Serial.println(", code for s, LED will wink slowly.");};
        if ((incomingByte!=102)&&(incomingByte!=115)) {
             Serial.println(". Only lower case s and f do anything.");};
     }
if (boFast)  {fastwink();};
if (!boFast) {slowwink();};
};

void fastwink()
{
digitalWrite(Out0,HIGH);
delay(80);
digitalWrite(Out0,LOW);
delay(80);
};

void slowwink()
{
digitalWrite(Out0,HIGH);
delay(900);
digitalWrite(Out0,LOW);
delay(900);
};

Once that's been uploaded to the Ardy, click on the last icon in the IDE's toolbar, and the serial monitor (controlling PCs end) starts up.

The LED should be on a fast wink at this point.

Enter "s" (just the letter, no quotes), and press enter. The LED should change over to winking slowly. Enter "f" to go back to fast.

There's more at....

... about the serial monitor, but not about writing programs which make the IDE your Arduino "HyperTerminal".

I would look at the Firmata stuff and look into interfacing it with Processing:
So I can't post links, but go to
playground / Interfacing / Processing and give that a read

Firmata/ Processing, are, I THINK... apologies, and please educate me if I am wrong!... mostly about what you put in the PC that is connected to the Arduino, to use stuff from it, and generate commands to be sent to it.

If you are looking for simpler "answers"... with a human "driving" the PC and reading stuff from the Ardy, and using grey cells and fingers to process the information and generate new commands, then you can use Hyperterminal, or even just the serial monitor built into the Arduino IDE.

I've started some pages about talking to Arduinos via serial data streams.

By the way, and not to "split" the tread, but: You may find that you have trouble finding Hyperterminal these days. Early experiences suggest that the freeware, Windows and Linux PuTTY may be a suitable replacement.

http://www.chiark.greenend.org.uk/~sgtatham/putty/

(For simple local serial comms, you only need to download the putty.exe file, which is The Program, not an installer.)

Firmata/ PRocessing, are, I THINK... apologies, and please educate me if I am wrong!.

No the Firmata is the code that is put in the arduino to allow the arduino library in processing to communicate and control the arduino.

Thank you for your replies. Firmata seems like a promising solution. I am hoping to write some software using C++ and hopefully have it function alongside the arduino. From what i can see the Firmata is a generic protocol so i should "Hopefully" be able to use in conjunction with C++.

I will have a play tonight and see what i can figure out.

Well, I did it. Thank you Arbit3r for giving me the push....

I finally.... I've tried many times.... written a Hyperterminal clone in Delphi... don't stop reading yet, folks.

Now if you want to write programs to interact with serial data into or out of an Arduino, without learning ANOTHER language (sigh), you probably can.. and certainly can if you already know Delphi.

The Delphi program doesn't do anything particularly Delphi-clever... it just "packages up" some standard Windows API calls. I'm sure the work would "translate" relatively easily into any other Windows-capable language. It would be a starting point for you, regardless of the OS in your "big" computer.

If you just want to send data FROM the big computer, to the Arduino, that is fairly simple.

The whole thing is written up at....

.... from which there are links to various related matters.

Enjoy! It's something I wanted to do for a LONG time... all sorts of projects become possible now that you've inspired me to break through that brick wall.

===
Thank you Mike for clarifying my mis-statement of what Firmata and Processing are!

First of all, thank you tkbyd for the guide you posted, you obviously put a huge amount of work into it.

Having never used Delphi before i have had a chance to mess around with it this weekend and have a look into creating the application in your guide. Although i have gone through your guide i am having some issues compiling the program after the.

procedure TDD80f1.WriteString(sToSend:string);
begin
//shell
end;

procedure TDD80f1.SendChars(sToSend:string);
begin
//shell
end;

function TDD80f1.SetUpSerPort:byte;
begin
//shell
end;

function TDD80f1.OpenForRead:byte;
begin
//shell
end;

function TDD80f1.OpenForWrite:byte;
begin
//shell
end;

Im not sure if im putting it in the right place but i have attached a screenshot for you to have a look at.

http://img651.imageshack.us/img651/4954/37366035.jpg

I know its something obviously stupid which im doing, but when you say "down at the bottom insert the following" i assume you are referring to inserting the code after the last procedure?

This is my full code so far. If you notice any bits from further into the tutorial its because i continued despite the errors on this section of code. But everything was compiling untill this step.

unit DD80u1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;


const ver='2 Apr 10';
RxBufferSize = 256;
   TxBufferSize = 256;
     //These constants are concerned with setting space
     //aside for buffering data to and from the serial
     //port. Make them too large, and space is wasted;
     //too small, and the buffers won't be adequate to
     //tide you over times when the computer's attention
     //is elsewhere. It may be that there are places in
     //the program where absolute values, or numbers from
     //other sources were used which should be replaced
     //with these constants.

type
  TLaVersion = class(TForm)
    buSendHello: TButton;
    buSendBye: TButton;
    buSeeIfTheresData: TButton;
    buQuit: TButton;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure buQuitClick(Sender: TObject);
    procedure buSendHelloClick(Sender: TObject);
    procedure buSendByeClick(Sender: TObject);

  private
    { Private declarations }
    sPortState:set of (c,w,r);//For closed, open for write, open for read
    hCommFile: THandle;
    bTmp:byte;
procedure WriteString(sToSend:string);
procedure SendChars(sToSend:string);
function SetUpSerPort:byte;
function OpenForRead:byte;
function OpenForWrite:byte;
  public
    { Public declarations }
  end;

var
  LaVersion: TLaVersion;
  DCB: TDCB;
   Config : string;
   CommTimeouts : TCommTimeouts;
   bErrCode:byte;

implementation

{$R *.dfm}
{$R+}



procedure TLaVersion.buSendByeClick(Sender: TObject);
begin
SendChars('Bye');
end;

procedure TLaVersion.buSendHelloClick(Sender: TObject);
begin
SendChars('Hello');
end;

procedure TLaVersion.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if sPortState<>[c] then closehandle(hCommFile);
//showmessage('x');//For testing that closehandle is done regardless
// of whether app closed with buQuit or red X. It is, as long as
// the buQuitClick handler is "close", not "application.terminate"

end;

procedure TLaVersion.FormCreate(Sender: TObject);
begin
sPortState:=[c];//Changed to [r] if handle set up
//to read from the port, or [w] if
//handle set up to write to the port
laVersion.caption:='DD80, version: '+ver;
top:=100;
left:=100;
end;

procedure TDD80f1.WriteString(sToSend:string);
begin
//shell
end;

procedure TDD80f1.SendChars(sToSend:string);
begin
//shell
end;

function TDD80f1.SetUpSerPort:byte;
begin
//shell
end;

function TDD80f1.OpenForRead:byte;
begin
//shell
end;

function TDD80f1.OpenForWrite:byte;
begin
//shell
end;

end.

The problem may be because you have a much grander version of Delphi than I do....

Did you, early in the tutorial, name your main form DD80f1? (That's supposed to be called for somewhere in the tutorial... apologies if I left it out.

A quick and dirty fix, that lets you go on from where you are, is to use LaVersion everywhere I've used DD80f1.

You may find that all you need to do is, even at this late date, rename your main form DD80f1. When you do that, various things should change, e.g. the line....

procedure TLaVersion.FormClose(Sender: TObject...

.... should become....

procedure TDD80f1.FormClose(Sender: TObject...

If that works, then you won't need to change the DD80f1s copied/pasted from the tutorial.

Hope that helps...

Tom

(P.S.: And yes, ther is a "T" in front of the DD80f1 inplaces.)

Thanks that helped. I ended up starting from scratch as i had made errors along the way which i had not noticed. You guide did mention to name the forum accordingly but i had not done so.

I am now confused with the second part of the tutorial, the large segment of code.

function TDD80f1.SetUpSerPort:byte;
//Call AFTER establishing hCommFile. Returns 0 if setup goes okay.

var
   DCB: TDCB;
   Config : string;
   CommTimeouts : TCommTimeouts;
   bErrCode:byte;

begin
bErrCode:=0;//Will eventually be returned. If zero, no error seen
if not SetupComm(hCommFile, RxBufferSize, TxBufferSize) then
   bErrCode:=1;
   { Raise an exception --- these comments
       all scraps of source material... will try to use exceptions in
       due course!}

if bErrCode=0 then //no "begin" here...  (this is part of kludge avoiding exceptions)
if not GetCommState(hCommFile, DCB) then
   bErrCode:=2;
   { Raise an exception }

Config := 'baud=9600 parity=n data=8 stop=1' + chr(0);

if bErrCode=0 then //no "begin" here...  (this is part of avoiding exceptions)
if not BuildCommDCB(@Config[1], DCB) then
   bErrCode:=3;
   { Raise an exception }

if bErrCode=0 then //no "begin" here...  (this is part of avoiding exceptions)
if not SetCommState(hCommFile, DCB) then
   bErrCode:=4;
   { Raise an exception }

if bErrCode=0 then //no "begin" here...  (this is part of avoiding exceptions)
with CommTimeouts do
begin
   ReadIntervalTimeout := 0;
   ReadTotalTimeoutMultiplier := 0;
   ReadTotalTimeoutConstant := 200;//This determines(?) how long
      //you stay in an attempt to read from serial port. milliseconds
      //I hope these routines are reading from a buffer managed by
      //the OS independently of these routines.
   WriteTotalTimeoutMultiplier := 0;
   WriteTotalTimeoutConstant := 1000;
end;

if bErrCode=0 then //no "begin" here...  (this is part of avoiding exceptions)
if not SetCommTimeouts(hCommFile, CommTimeouts) then
   bErrCode:=5;
   { Raise an exception }

result:=bErrCode;
end;//function SetUpSerPort:byte;

I have tried to integrate it with no luck. Your guide has been very noob friendly and clear up to this point where i have become a bit lost.

If you could explain how im supposed to integrate it into the the rest of the code it would be appreciated.