Show Posts
Pages: [1] 2
1  Forum 2005-2010 (read only) / Troubleshooting / Re: Can I pay someone to write a sketch for me? on: August 30, 2009, 06:29:04 am
Take a look here, might get you started:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1187962258

http://tomscarff.110mb.com/midi_analyser/midi_analyser.htm

http://www.arduino.cc/playground/Main/InterfacingWithHardware#Communication   (scroll down to MIDI section)
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: Boolean Vs. Bitwise on: October 07, 2009, 12:34:39 am
There is a really good tutorial covering bit math and the do's and dont's by CosineKitty.

It cleared alot up for me (had a hard time understand bit math before I read it).

Highly recommended.
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: '001001' string over serial to bit operations? on: October 07, 2009, 12:31:04 am
Thank you for your reply, much appreciated!

I deleted the other topic, it timed out on me when creating it so I guess
something was not right serverside.

I will try your suggestions asap!

I tried to convert the string to integer, byte you name it, but it always errored out
on me. This problem has made me go almost completely bald...  smiley-wink

Thanks again!
4  Forum 2005-2010 (read only) / Syntax & Programs / '001001' string over serial to bit operations? on: October 06, 2009, 02:34:17 pm
Hello,

I am struggling with a string to byte conversion and I can't seem to get it right...

I am sending a string like 001001 over serial and my Duemilanove receives it.
Now, using the received string, I'd like to set pins high/low depending of the
string contents and here is where I can't seem to get it right.

Does anyone have information of how I could treat the received string as a byte
in Arduino code (looking to do bitwise operations)?

A snippet:

Code:
byte G = B100000;
byte R = B010000;
byte Y = B001000;

void loop() {
  inCount = 0; // Reset the serial char counter
    while (Serial.available() > 0){ // wait for input
      inString = Serial.read(); // get it
      delay(1);
      if (inCount == 6) break;
      inCount++;

if ((inString&G) == G) {digitalWrite(GreenPin, HIGH);} else {digitalWrite(GreenPin, LOW);}
  if ((inString&R) == R) {digitalWrite(RedPin, HIGH);} else {digitalWrite(RedPin, LOW);}
  if ((inString&Y) == Y) {digitalWrite(YellowPin, HIGH);} else {digitalWrite(YellowPin, LOW);}

5  Forum 2005-2010 (read only) / Syntax & Programs / Re: Incoming data to array? ( I think ) on: September 05, 2009, 08:56:49 am
I'm a newbie, but try nullterminate your buffer. Here's some code that works for me, PC sends strings through serial and Arduino is receiving and replying.

Code:
char inString[32];                            // length inString
int inCount;
int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);                         // initialize serial communication
}

void loop()
  {
  inCount = 0;
  
  while (Serial.available() > 0)
  {                                               // wait for input
  digitalWrite(ledPin, HIGH);                     // set the LED on
  inString[inCount] = Serial.read();              // get it
  delay(10);
      //Serial.print("I received: ");             // DEBUG
      //Serial.println(inString[inCount], BYTE);  // DEBUG
  if (inString[inCount] == '\0') break;
  inCount++;
  }
  
  inString[inCount] = '\0';                       // nullterminate the received string
  digitalWrite(ledPin, LOW);                      // set the LED off
  
  //if (inCount > 0) {                            // DEBUG
  //Serial.print("The completed string: ");       // DEBUG
  //Serial.println(inString);                     // DEBUG
  //}
  
  if (strcmp(inString, "Hello?") == 0)            // compare received string
  {        
      digitalWrite(ledPin, HIGH);
      Serial.println("Yes! I am here!");          // reply
      delay(1000);
      digitalWrite(ledPin, LOW);
  }
  if (strcmp(inString, "Who are you?") == 0)      // compare received string
  {  
      digitalWrite(ledPin, HIGH);
      Serial.print("I am");     // reply
      delay(250);
      Serial.print(".");
      delay(250);
      Serial.print(".");
      delay(250);
      Serial.print(".");
      delay(1500);
      Serial.println(" Duemilanove!");
      digitalWrite(ledPin, LOW);
  }  
}
6  Forum 2005-2010 (read only) / Interfacing / Re: Strange Serial Port Problems on: October 08, 2009, 06:10:21 am
Why not put the timing/LED program on the Arduino and just have the Arduino react to the string you are sending over serial?
7  Forum 2005-2010 (read only) / Interfacing / Re: GH Bot on: September 28, 2009, 02:52:47 am
Josh,

Buhric (forum member) have made a 'visual' GH bot that does exactly what you describe. However, the sources/programs used are custom made and not available publicly:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1249435156

Another 'visual' GH bot is the 'DaveyBot' and comes complete with software and source:

http://forums.adafruit.com/viewtopic.php?f=25&t=10656

I am working on a bot as well, but for the moment it is 'blind' since I don't have a webcam or a capture card  :-/
8  Forum 2005-2010 (read only) / Development / Re: is there an Arduino example for Delphi? on: November 10, 2009, 12:42:09 pm
For what it's worth, I moved to TComPort instead (available at Sourceforge) and use start/end packets with my serialdata transmitted from Arduino which I process further in my Delphi app.

My personal opinion is that this is easier - even if it means that you need to encapsulate the serial sent from Arduino with your start/end packets.
9  Forum 2005-2010 (read only) / Development / Re: is there an Arduino example for Delphi? on: August 29, 2009, 02:32:16 am
From the synaser site:

Code:
procedure Config(baud, bits: integer; parity: char; stop: integer; softflow, hardflow: boolean); virtual;

Reconfigure communication parameters on the fly. You must be connected to port before!
parameters

Code:
baud
    Define connection speed. Baud rate can be from 50 to 4000000 bits per second. (it depends on your hardware!)
bits
    Number of bits in communication.
parity
    Define communication parity (N - None, O - Odd, E - Even, M - Mark or S - Space).
stop
    Define number of stopbits. Use constants SB1, SB1andHalf and SB2.
softflow
    Enable XON/XOFF handshake.
hardflow
    Enable CTS/RTS handshake.

The code above works - but like I said, I am not a very experienced coder.

Then again, this maybe would have been clearer (using the constants)?

Code:
Config(9600, 8, 'N', SB1, False, False)
10  Forum 2005-2010 (read only) / Development / Re: is there an Arduino example for Delphi? on: August 28, 2009, 01:29:14 pm
Created my first Arduino sketch (ever) and hacked together a little Delphi-app with Synaser as the serial comm.

Both the sketch and the Delphi code could surely be better and optimized, but I am a newbie in both languages, so... The effect in the reply to 'Who are you?' gets lost in the Delphi-app, but is clearly visible in the serial monitor.

Arduino:
Code:
char inString[32]; // length inString
int inCount;
int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600); // initialize serial communication
}

void loop()
  {
  inCount = 0;
  
  while (Serial.available() > 0)
  { // wait for input
  digitalWrite(ledPin, HIGH);           // set the LED on
  inString[inCount] = Serial.read(); // get it
  delay(10);
      //Serial.print("I received: "); // DEBUG
      //Serial.println(inString[inCount], BYTE); // DEBUG
  if (inString[inCount] == '\0') break;
  inCount++;
  }
  
  inString[inCount] = '\0'; // nullterminate the received string
  digitalWrite(ledPin, LOW); // set the LED off
  
  //if (inCount > 0) { // DEBUG
  //Serial.print("The completed string: "); // DEBUG
  //Serial.println(inString); // DEBUG
  //}
  
  if (strcmp(inString, "Hello?") == 0) // compare received string
  {        
      digitalWrite(ledPin, HIGH);
      Serial.println("Yes! I am here!"); // reply
      delay(1000);
      digitalWrite(ledPin, LOW);
  }
  if (strcmp(inString, "Who are you?") == 0) // compare received string
  {  
      digitalWrite(ledPin, HIGH);
      Serial.print("I am"); // reply
      delay(250);
      Serial.print(".");
      delay(250);
      Serial.print(".");
      delay(250);
      Serial.print(".");
      delay(1500);
      Serial.println(" Duemilanove!");
      digitalWrite(ledPin, LOW);
  }  
}

Delphi:
Code:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    HelloBtn: TButton;
    WhoBtn: TButton;
    ConBtn: TButton;
    procedure ConBtnClick(Sender: TObject);
    procedure HelloBtnClick(Sender: TObject);
    procedure WhoBtnClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  ComPort : string = 'COM3'; // Change this to suit your config
  Ser : TBlockSerial;
  
implementation

{$R *.dfm}

procedure TForm1.ConBtnClick(Sender: TObject);
begin
      Ser := TBlockSerial.Create;
  try
    Ser.Config(9600, 8, 'N', 0, False, False);
    Ser.Connect(ComPort);

    Ser.Purge;
    Ser.Flush;
    if Ser.LastError = 0 then
    begin
          Memo1.Lines.Add(ComPort + ' connected!');
      WhoBtn.Enabled := True;
      HelloBtn.Enabled := True;
      ConBtn.Enabled := False;
    end
    else
    begin
      Memo1.Lines.Add('Cannot connect to ' + ComPort);
    end;
  finally
    //Ser.Free;
  end;
end;

procedure TForm1.HelloBtnClick(Sender: TObject);
var
Rcvd : string;
begin
Rcvd := '';
HelloBtn.Enabled := False;
if Ser.LastError = 0 then
begin
  Memo1.Lines.Add('');
  Memo1.Lines.Add('>> Sending hello...');
  Memo1.Lines.Add('');
  Ser.SendString('Hello?');
  if Ser.CanRead(3000) then
  begin
        Rcvd := Ser.Recvstring(3000);
  end;
  Memo1.Lines.Add('<<< ' + Rcvd);
  //Ser.Purge;  
end;
HelloBtn.Enabled := True;
end;

procedure TForm1.WhoBtnClick(Sender: TObject);
var
Rcvd : string;
begin
Rcvd := '';
WhoBtn.Enabled := False;
if Ser.LastError = 0 then
begin
  Memo1.Lines.Add('');
  Memo1.Lines.Add('>> Sending identity request...');
  Memo1.Lines.Add('');
  Ser.SendString('Who are you?');
  if Ser.CanRead(10000) then
  begin
        Rcvd := Ser.Recvstring(10000);
  end;
  Memo1.Lines.Add('<<< ' + Rcvd);
  //Ser.Purge;  
end;
WhoBtn.Enabled := True;
end;

end.
11  Forum 2005-2010 (read only) / Development / Re: is there an Arduino example for Delphi? on: August 27, 2009, 05:21:46 am
Thanks DaveK.

I messed around a bit with Synaser yesterday and it seems to me that it will manage the serial task quite well.
12  Forum 2005-2010 (read only) / Development / Re: is there an Arduino example for Delphi? on: August 21, 2009, 09:57:28 am
Quote
I'm would like to make my arduino send signals to a delphi program that logs the actions.. But I'm never used serial communications before.

My intentions are that then there is a signal on one of the contacts on the arduino ( say pin 8 ) the arduino sends a number och letter to the delphiprogram. The program timestamps it and write it to a file.

The file is then read by a webpage... But that is another story.. Smiley

I should be able to write the arduino-program and what delphi should do with the info sent, but the reciveing part of it... I have NO idea how to fix that.

Is there anyone who can help me..

/Senil

I am looking to do the same.  smiley
13  Forum 2005-2010 (read only) / Scandinavia / Re: Where to purchase Arduino components in Finland? on: September 08, 2009, 05:28:07 am
I can personally recommend Lawicel for your Arduino needs. They are located in Sweden, but ships to Finland as well.

Did I mention they stock several of the Sparkfun applications as well?  smiley-grin

You can check their site out @ http://www.lawicel-shop.se
14  Forum 2005-2010 (read only) / Interfacing / Re: Simple timestamp in serial window? on: October 09, 2009, 02:46:10 am
Wouldn't it be easier if Processing timestamped the received data instead?

I am not sure, but I think you would need either a circuit with a realtime clock (on the Arduino) or have a variable in your sketch that syncs with the current time retrieved from a computer or application as the Arduino don't have a 'clock' in itself keeping the time (except for millis() keeping the millisecs from the start of the sketch).

I hope someone could chime in whether or not the above is true.
15  Forum 2005-2010 (read only) / Exhibition / Re: AutoPlay of Guitar Hero using Arduino Nano on: August 27, 2009, 04:59:43 am
Thanks, the obstacle now is the software for the noterecognition (if I were to replicate your bot).

I am thinking of maybe hooking the guitar up to the Duemilanove (frets and strum) and while playing practice versions of the songs, the Duemilanove 'senses' the frets - but only when I strum - and timestamps the strum + frets, sends this to an application on the PC for saving/editing.

I have checked the tutorials regarding buttons and 'sensing' and it seems that it would be enough to connect a digital pin to a fret button and then check the pin state to see if the button is pressed or not (HIGH/LOW)? Or, would I need to hook up the guitar controller circuit to the Duemilanove in order to be able to sense the button press?
Pages: [1] 2