Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 10
61  Forum 2005-2010 (read only) / Interfacing / Re: Arduino to MATLAB on: March 09, 2007, 05:36:52 pm
Is this something you could do by loading a properly-formatted text file into MATLAB?  I'm speaking with utter ignorance of what MATLAB allows you to do... I mean, I know it has something to do with math, but other than that... EEK!  smiley

Anyway, perhaps you could Serial.print() properly formatted text, capture that text with a serial terminal program, save to a file, then load that into MATLAB?
62  Forum 2005-2010 (read only) / Interfacing / Re: Arduino and 1-wire on: January 05, 2007, 03:04:01 pm
This line of code scares my kitty cat    smiley-wink

 if (digitalRead(DQ == LOW))

This compares DQ to LOW (7 == 0), which evaluates to false, or 0, then does a digitalRead of pin 0 and asks whether it returned HIGH or not.

I think you meant:

 if (digitalRead(DQ) == LOW)

But hey, maybe it works anyway... ????
63  Forum 2005-2010 (read only) / Interfacing / Re: translating strings to hex/dec/bin on: January 08, 2007, 10:52:04 am
Ahhh... that makes more sense now.  So you could just use my WaitAndRead(), and check the return value against '8' (not 8, but '8', the character in single quotes).  8 == 8, but '8' == 56, as  kg4wsv mentioned.
64  Forum 2005-2010 (read only) / Interfacing / Re: translating strings to hex/dec/bin on: January 07, 2007, 09:13:09 pm
See also this thread, for the dangers of calling without checking for -1 (no character ready):

I am also a little confused here because you give "XFF100000" as a sample string, which appears to be "X" followed by 8 hex digits, which is a 32-bit integer.  But you say you are trying to scan this into a value 0..255?  I guess you mean the first 2 hex digits, ignoring the remaining 6?

Here is how I would read 2 hex digits and convert them into a byte value from 0..255:

byte WaitAndRead()
    while (Serial.available() == 0) {
        // do nothing
    return (byte);

int SerialReadHexDigit()
    byte c = WaitAndRead();
    if (c >= '0' && c <= '9') {
        return c - '0';
    } else if (c >= 'a' && c <= 'f') {
        return c - 'a' + 10;
    } else if (c >= 'A' && c <= 'F') {
        return c - 'A' + 10;
    } else {
        return -1;   // getting here is bad: it means the character was invalid

int SerialReadHexByte()
    byte a = SerialReadHexDigit();
    byte b = SerialReadHexDigit();
    if (a<0 || b<0) {
        return -1;  // an invalid hex character was encountered
    } else {
        return (a*16) + b;
65  Forum 2005-2010 (read only) / Interfacing / Re: Strange Bug related to Baud Rate on: February 15, 2007, 05:29:18 pm
It might be helpful if you posted your entire code.  The one line you posted looks fine, so the bug is probably somewhere else in the code.  I use many different baud rates via Serial.begin(), and I have never had a problem like this.
66  Forum 2005-2010 (read only) / Interfacing / Re: Serial interfacing with Win32 console app on: January 07, 2007, 09:03:20 pm
Here is a snippet of code from one of my C++ programs for opening a com port as a handle.
You have to open it as "\\.\com1" for example.  Of course in C++, a backslash in a string has to be doubled to avoid it being treated as an escape sequence (gee, thanks Microsoft, for not using "/" like Unix does!).

           char comport_name [64];
            sprintf (comport_name, "\\\\.\\COM%d", comport);
            HANDLE comhandle = CreateFileA (
                0,                  // no sharing
                NULL,               // default security attributes
67  Forum 2005-2010 (read only) / Development / Re: Arduino timer interrupt on: December 24, 2006, 09:07:58 pm
This is a total shot in the dark, but when you do this:

    TCCR2 |= ((1<<CS22) | (0<<CS21) | (0<<CS20));

is it possible that other bits are already set in TCCR2?  Doing a bitwise-OR between a zero and a bit that is already set to 1 will leave that bit at 1, not change it to zero.  For example, when you do the following line:

    TCCR2 |= (0<<WGM21) | (0<<WGM20);

You are not changing the value of TCCR2, no matter what its current value, because it is the same as saying:

    TCCR2 = TCCR2 | 0;

If you really want to make sure a bit is turned off, you should use &= and the bitwise not operator ~.  So why not try replacing these lines of code:

  //Timer2 Settings: Timer Prescaler /64,
  TCCR2 |= ((1<<CS22) | (0<<CS21) | (0<<CS20));  
  // Use normal mode
  TCCR2 |= (0<<WGM21) | (0<<WGM20);

with the following lines:

  //Timer2 Settings: Timer Prescaler /64,
  TCCR2 |= (1<<CS22);    // turn on CS22 bit
  TCCR2 &= ~((1<<CS21) | (1<<CS20));    // turn off CS21 and CS20 bits
  // Use normal mode
  TCCR2 &= ~((1<<WGM21) | (1<<WGM20));   // turn off WGM21 and WGM20 bits

Like I said, this is a total guess, because I have no idea what these things are, but I think this is at least closer to what you intended.   Let us know how it works...

- Don
68  Forum 2005-2010 (read only) / Development / Re: Windows command line build on: September 10, 2008, 03:08:33 pm
Hi makingthenoise,

I have added a "-u" option to upload immediately without prompting.
Let me know how this works in Eclipse.

- Don
69  Forum 2005-2010 (read only) / Development / Re: Windows command line build on: September 10, 2008, 06:18:45 am
I have made minor fixes to all 3 batch files (abuild.bat, aupload.bat, agetpref.bat).
They are available now at

You may need to click on each txt file, then hit "reload" or "refresh" in your browser, otherwise you may still  see the old version (this just happened to me in Firefox).

Here is what I did:
  • Checked raptorofaxys changes into my personal cvs repository so that his contributions are logged in the comments at the end of the files.
  • I fixed a problem with the -c option not working in abuild.bat.
  • In aupload.bat, I fixed a typo in the error message displayed when more than one hex file is found.
  • Included a link to this forum thread in the help text.
  • Updated displayed release dates to September 10, 2008.

Please report any bugs, issues, or questions here.


- Don
70  Forum 2005-2010 (read only) / Development / Re: Windows command line build on: September 06, 2008, 11:03:37 am
I have been away for a long time, and haven't come back to see the status of this project I started over a year ago.

I see that there were some problems with Arduino 11, and Raptorofaxys has been very helpful in posting a workaround at

Thanks, Raptor!  I think you were a bit modest about calling your modifications "slight"  smiley  You did quite an overhaul there.

It looks like there is a lingering bug left over from my original version of abuild.bat: the "-c" option does not work.  I believe the following code:

if /i "%1" == "-c" (
    set abuild_upload=false

should be changed to:

if /i "%1" == "-c" (
    set abuild_upload=false
    goto NextOption

Somehow I missed this when posting the batch files last year.  Raptor, shall I fix this, or would you like to?  I want to coordinate so we don't end up overwriting each other's changes.

As another topic, it might be nice to add an option for getting the burner options using one of the board names from the file:


Something like:

    set ARDUINO_BOARD=atmega8

Then agetpref.bat could search through boards.txt and find:


This would greatly reduce the number of environment variables needed by anyone using a stock configuration.  Would you like to collaborate on this?

Thanks again,

- Don
71  Forum 2005-2010 (read only) / Development / Re: Windows command line build on: March 09, 2007, 06:03:15 pm
OK, actually it turned out to be a lot simpler to fix than I thought! smiley

I have fixed the batch file abuild.bat in the Playground:

Delete your existing abuild.bat, download the above, then rename it from abuild.txt to abuild.bat.

You will need to remove the double-quotes (") from your calling batch file:

set ARDUINO_PATH=c:\Program Files\arduino-0007

Let me know how it works...

- Don
72  Forum 2005-2010 (read only) / Development / Re: Windows command line build on: March 09, 2007, 05:46:28 pm
Wait... never mind.  I see what the problem is:  my batch files cannot cope with spaces in the ARDUINO_PATH, with or without quotes.  I am working on a fix, but in the mean time, you could try moving the entire directory "c:\program files\arduino-0007" to "c:\arduino-0007", then do:

set ARDUINO_PATH=c:\arduino-0007

When I get the spaces issue fixed, I will update the batch files on the Playground and post a message here.  (It may take me a couple of days to get around to it.)

- Don
73  Forum 2005-2010 (read only) / Development / Re: Windows command line build on: March 09, 2007, 05:32:28 pm
Hmmm... I am not sure, but I would try changing the line:

SET ARDUINO_PATH="C:\Program Files\arduino-0007"


SET ARDUINO_PATH=C:\Program Files\arduino-0007

Make absolutely sure you have NO SPACES at the end of this line also.
74  Forum 2005-2010 (read only) / Development / Re: Windows command line build on: January 09, 2007, 01:31:50 pm
Given that we already are using cygwin style tools, I don't think it would be that hard to add these utilities to the arduino-win distribution.

That would be great!  In the meantime, you and I could assemble links and instructions into a page on the Playground so that people could use either method.

Another thing to consider:  I am proposing changes to Arduino 0008 that will make many sketches compile to much smaller binaries.  This requires changing some Java code in the Arduino IDE, splitting up lib/targets/arduino source code into smaller source files, and (relevant to this discussion) reworking the build process to link in the runtime as a library instead of object files.  It would be nice to see if we can change the makefile to work with my library patch... see here:

The windows batch files I wrote are designed to work with either the original Arduino 0007 distribution, or with the library patch above.

Incidentally, that is why my batch files make smaller binaries; and if you use the library patch also, they get a LOT smaller!
75  Forum 2005-2010 (read only) / Development / Re: Windows command line build on: January 08, 2007, 06:23:09 pm
If there was a top-level batch file called "make" then the windows command line build would start to look more like the unix one.
Feel free to rename abuild.bat to make.bat ... it's YOUR computer, after all!  smiley
Seriously, I didn't want to call it "make" because I didn't want to introduce conflicts with somebody who had a genuine make utility already there.

it might be easier to just crib one .exe than to have a whole system of batch files.
The reason I did all this work was because I was going to use the makefile, so I started looking for a Windows version of make.  Then I realized I needed grep and sed also, which meant I was going to need to find them, hope they were compatible, blah blah blah.  It seemed like too much hassle for every single Windows user of Arduino to have to go through.  So now you don't have to search for anything; just download 3 batch files, put them in your path, set your ARDUINO_PATH environment variable, and you're done.  Run abuild.bat and it will call the other 2 batch files as needed.

Oh, and did I mention your binaries will be smaller than with the ones the Makefile or the IDE will produce?
Pages: 1 ... 3 4 [5] 6 7 ... 10