Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 67
61  Using Arduino / Programming Questions / Re: "Hourglass" without delay - understanding if, while, & for loops on: May 05, 2013, 08:11:17 pm
You are not guaranteed to see every millisecond via millis(); sometimes it skips one, which would botch your % 60000 scheme, wouldn't it?

It would be much more reliable to use the difference in time, instead of time % 60000, to trigger the turn-off-leds section.  You can see an example of this in the Blink Without Delay sketch.

Adding UL makes the constant Unsigned Long so the arithmetic is not demoted to 16-bit as is default in C.  A frequent gotcha.

-br

Edit: sorry, posted too fast.  Why not move the part that turns the lights on to setup(), and make a nice outer timer at 60000 ms that runs the inner lights-off timer.

62  Using Arduino / Programming Questions / Re: "Hourglass" without delay - understanding if, while, & for loops on: May 05, 2013, 07:59:46 pm
Does it work any better if you replace this:
Code:
while (previousMillis % 60000 != 0){
with this:
Code:
while (previousMillis % 60000UL != 0){

-br
63  Using Arduino / Programming Questions / Re: Program causes MCU to hang on boot on: May 05, 2013, 07:42:43 pm
The first thing I would eliminate is an out-of-RAM condition.  It's of particular interest because of all the strings you Serial.print(). 

A quick way to buy back a bunch of ram is to enclose the strings in your serial print statements in F(), like this:
Code:
Serial.print("xyz");     // change this
Serial.print(F("xyz"));  // into this

Try that in all your Serial.print strings and see if it helps...

-br


64  Using Arduino / Programming Questions / Re: integer to char on: May 05, 2013, 09:57:43 am
It is not necessary to concatenate two things to print them out one after the other.

-br
65  Using Arduino / Networking, Protocols, and Devices / Re: 2 arduino mega comunikate together on: May 05, 2013, 07:25:33 am
Well you could check out Bitlash, which might be suitable for your project:

http://bitlash.net

You could write a program for master unit A to drive Bitlash on slave unit B.

-br
66  Using Arduino / Networking, Protocols, and Devices / Re: 2 arduino mega comunikate together on: May 05, 2013, 07:05:30 am
Sure, you could write a sketch to do that.  A pair, actually, one for each device.

-br
67  Using Arduino / Programming Questions / Re: long from byte - one substracted? on: May 04, 2013, 06:20:41 pm
Love a little code golf.  This problem can be worked without any arithmetic using a C union to allow two views of the same static memory:
Code:

union {
long thelong;
byte thebytes[4];
} u;

void setup() {
Serial.begin(57600);
}

void loop() {
u.thebytes[3] = 0x00;
u.thebytes[2] = 0x69;
u.thebytes[1] = 0xa8;
u.thebytes[0] = 0xc4;
Serial.print(u.thelong, HEX);
delay(10000);
}

Prints 69A8C4

-br
68  Using Arduino / Programming Questions / Re: bad code or a bug? on: May 04, 2013, 05:52:38 pm
Does it work any better if you use integer calculations (1<<31) instead of floating point pow(2,31)?

-br
69  Using Arduino / Networking, Protocols, and Devices / Re: WiFi sheild - can read HTML from some, but not all sites. Why? on: May 04, 2013, 05:28:50 pm
That domain looks normal from here via browser and curl.

Are you familiar with Wireshark?  It might be time to do a little packet sniffing to watch the TCP connection setup that's not working.

-br
70  Using Arduino / Networking, Protocols, and Devices / Re: WiFi sheild - can read HTML from some, but not all sites. Why? on: May 04, 2013, 05:11:24 pm
So you're seeing "Connected to network…" followed by "No connection…"?

-br
71  Using Arduino / Networking, Protocols, and Devices / Re: WiFi sheild - can read HTML from some, but not all sites. Why? on: May 04, 2013, 04:55:08 pm
Properly forming the GET request might help:

Code:
      client.println("GET / HTTP/1.1");

-br
72  Using Arduino / Networking, Protocols, and Devices / Re: WiFi sheild - can read HTML from some, but not all sites. Why? on: May 04, 2013, 04:40:12 pm
You're probably not sending a proper Host: header.

Post all your code, in code tags, and you'll get a better answer…

-br
73  Using Arduino / Project Guidance / Re: Too many pins used!! on: May 04, 2013, 04:01:01 pm
You can't use 0 and 1 without losing access to Serial.read() and Serial.print().

I don't understand why you are having problems with pin 2.

-br
74  Using Arduino / Project Guidance / Re: Too many pins used!! on: May 04, 2013, 03:25:55 pm
The shield uses what it uses.

You can use the analog inputs as digital inputs or outputs, if that helps.


-br
75  Using Arduino / Networking, Protocols, and Devices / Re: LED will not turn on and off with Ethernet shild on: May 04, 2013, 06:58:48 am
I don't see anywhere you set the pinMode(2, OUTPUT); -- that can lead to the symptom of "dim LED".

-br
Pages: 1 ... 3 4 [5] 6 7 ... 67