Show Posts
Pages: 1 ... 22 23 [24] 25 26 ... 33
346  Using Arduino / Networking, Protocols, and Devices / Re: xBee.h doesn't compile with leonardo - Serial problem on: June 25, 2012, 08:02:32 pm
I made the change and made sure I closed then re-opened the Arduino IDE, but my sketch didn't compile when I selected the Leonardo board.  I got this error:

/Volumes/srg/Arduino Sketches/libraries/XBee/XBee.cpp: In constructor 'XBee::XBee()':
/Volumes/srg/Arduino Sketches/libraries/XBee/XBee.cpp:774: error: cannot convert 'Serial_*' to 'HardwareSerial*' in assignment
347  Using Arduino / Networking, Protocols, and Devices / Re: xBee.h doesn't compile with leonardo - Serial problem on: June 25, 2012, 01:32:00 pm
That worked, thanks.   In the \libraries\ folder I created a new directory called \XBee_Leo and copied XBee.h and XBee.cpp in there and renamed them to XBeeLeo.h and XBeeLeo.cpp.  In the XBeeLeo.cpp I made the serial1 change and changed #include XBee.h to #include XBeeLeo.h.  In my sketch I just changed the include from <XBee.h> to <XbeeLeo.h> and all is good. 

It would be nice if one library could compile both Leonardo boards and non-Leonardo boards. I tried some stuff with #ifdef, but it didn't work.  Here's what I tried:
First I changed added a #define to my sketch:
Code:
#define LEONARDO
#include <XBee.h>
In XBee.cpp, I changed
Code:
_serial = &Serial;
to
Code:
#ifdef LEONARDO
   _serial = &Serial1;
#else
   _serial = &Serial;
#endif

But this didn't work.



348  Using Arduino / Networking, Protocols, and Devices / Re: xbee Coordinator - is this Tx or Rx on: June 23, 2012, 06:20:28 pm
I figured it out, the Coordinator is the xbee receiver.
349  Using Arduino / Programming Questions / Re: Best practice for digitalWrite() on: June 23, 2012, 11:11:21 am
While it won't make much difference from a power perspective, it can make a big difference from a timing perspective.
From a timing perspective, digitalWrite() is very time consuming for what it does.

I was thinking about doing a little test for that, now I don't have to.  What about digitalRead() an analogRead(), do they take up as much time as digitalWrite()?
350  Using Arduino / Networking, Protocols, and Devices / xbee Coordinator - is this Tx or Rx on: June 23, 2012, 10:12:48 am
I am trying out the examples that came with xbee.h library.  I configured my two xbees, one as coordinator and one as the end device.  There is a sample Tx and sample Rx sketch (I'm using Series 1).  Should I load the Tx sketch onto the Arduino with the coordinator xbee?
351  Using Arduino / Networking, Protocols, and Devices / xBee.h doesn't compile with leonardo - Serial problem on: June 23, 2012, 09:46:34 am
I am trying to use xbee.h (http://code.google.com/p/xbee-arduino/) with the new Leonardo.  I get this error when I verify the sketch:
769: error: cannot convert 'Serial_*' to 'HardwareSerial*' in assignment

I assume it has something to do with the Leonardo not using serial by default and you have to use Serial1 or something, but I don't know what code to change to fix this.  Can anyone help?

--Scott
352  Using Arduino / Programming Questions / Re: Best practice for digitalWrite() on: June 22, 2012, 07:42:40 pm
Neither sketch ever actually assigns a value to turnMeOn, so neither will ever actually turn the pin on.

I didn't intend to put a complete working sketch, I just wanted enough code so my question was clear.
353  Using Arduino / Programming Questions / Best practice for digitalWrite() on: June 22, 2012, 07:23:16 pm
If I want to turn something on with digitalWrite() there are two ways I can code this.  I'm wondering if one is preferable to the other. 
The first method is to execute the digitalWrite() command in every loop of the sketch, like this:
Code:
void loop()
{
  static bool TurnMeOn;
  if(TurnMeOn == true)
  {digitalWrite(MyPin, HIGH);}
  else
  {digitalWrite(MyPin, LOW);}
}

The second is to turn the output on once, and not do it every loop. For example:
Code:
void loop()
{
  static bool TurnMeOn;
  static bool OutputIsOn;
  if(TurnMeOn == true && OutPutIsOn == false)
  {
    digitalWrite(MyPin, HIGH);
    OutPutIsOn = true;
  }
  else
 {
  digitalWrite(MyPin, LOW);
  OutPutIsOn = false;
 }
}
Does is make any difference between these two methods?

354  Using Arduino / Networking, Protocols, and Devices / Re: Leonardo Digital Pins 0 and 1 on: June 18, 2012, 07:00:07 am
Thanks.  I know nothing about serial interface, but I do have a project that uses an xbee.  I wonder if there is any advantage of using pins 0 and 1 with the xbee.  If so, I'm assuming a library would have to be written to take advantage of the UART.
355  Using Arduino / Networking, Protocols, and Devices / Leonardo Digital Pins 0 and 1 on: June 17, 2012, 10:19:39 pm
Looking at the Leonardo info, it seems it doesn't use digital pins 0 and 1 anymore, at least not by default.  I just wanted to double check - can I now use these pins for my sketches?
356  Using Arduino / Installation & Troubleshooting / Re: Leonardo doesn't send to Serial Monitor after software reset on: June 17, 2012, 10:06:16 pm
I'm surprised that it doesn't work when you use the watchdog timer.  Can you provide more details (e.g. a sample sketch and the behavior you see)?

Attached is my sketch.  The watch dog timer is disabled, you'll need to uncomment // #define WDT on line 17 of Humidity_716Basement_v2.ino to enable the WDT.
357  Using Arduino / Installation & Troubleshooting / Leonardo doesn't send to Serial Monitor after software reset on: June 16, 2012, 04:44:43 pm
I have Arduino 1.01 and a Leonardo with an Ethernet shield (R3).  My sketch is designed to do a reset if there is a communication problem, to test this I just unplug the cable from the Ethernet shield.  The Arduino resets using  asm volatile ("  jmp 0"); 
The reset works fine and the Arduino continues uploading to COSM.com via the Ethernet shield, but if I had the serial monitor open, I don't see any text after the reset.  Even if I close the serial monitor and re-open it, still nothing.  I know the Leonardo works a little differently then the UNO with the serial monitor.  Is there anything I can do to get the Arduino to recognize the serial monitor after a reset.  The serial monitor works fine when I upload a new sketch, it's just after a reset I have a problem.  I had also tried resetting with the Watch Dog Timer, and I have the same serial monitor issue with that method also.  If I close the serial monitor then do a hard reset (using the PCB pushbutton), the serial monitor works again.

358  Using Arduino / Programming Questions / Re: strncpy() causes reset on: April 18, 2012, 11:40:53 am
You should move your Serial.print strings to PROGMEM.

A lazy way is to use the Serial.print(F("ahaqoihio"));
Unless every output string is unique you are duplicating strings in PROGMEM.

I'm going to do that.  I learned a lot about strings and RAM in trying to debug this problem.
359  Using Arduino / Programming Questions / Re: strncpy() causes reset on: April 18, 2012, 08:05:45 am
I'll never understand why Microsoft invented a bunch of complex templates for casting, and why anyone uses them.

Code:
char *reply = (char *)(ether.tcpReply(session));

No templates; smaller footprint; easier (for me) to understand.

I like your method better. 
360  Using Arduino / Programming Questions / Re: strncpy() causes reset on: April 17, 2012, 10:03:15 pm
I got it working.  I shortened a bunch of strings in my Serial.print() statements and that freed up some RAM.

I also figured out how to cast my const char to char:
char* reply = const_cast<char*> (ether.tcpReply(session));

I'm not changing the reply string, so I felt comfortable doing this.
Pages: 1 ... 22 23 [24] 25 26 ... 33