Show Posts
Pages: 1 2 3 [4] 5 6 ... 67
46  Using Arduino / Networking, Protocols, and Devices / Re: PHP data transfer with official Wifi shield on: May 08, 2013, 05:10:29 pm
If you think about it, it's highly unlikely that there will be any data for several hundred milliseconds at least, as your GET request goes to the server, your script runs, and the result comes back.  Your client.available call is about zero milliseconds after the GET request, so of course it returns false.

You need a little loop to hang out and _wait_ for client.available to go true, and then read/print until it goes false.

For style points, add a timeout...

-br
47  Using Arduino / Networking, Protocols, and Devices / Re: PHP data transfer with official Wifi shield on: May 08, 2013, 03:44:02 pm
Code:
 String url = "http://my_website.com/update.php?ID=1&DATA=0";
Using the String class risks memory fragmentation and the kind of occasional crash that is one of the symptoms you're complaining about.

Change this to char url[] = "http://..." and it might be more reliable.

-br

Update: in order to get the response back from the PHP script, you will need to client.read() all the characters it sends, and perhaps print them.
48  Using Arduino / Programming Questions / Re: How to pass variable to library? on: May 08, 2013, 08:51:43 am
For a working example, take a look at bitlash.cpp and bitlash.h here: https://github.com/billroy/bitlash

It would help to see B.cpp and B.h to confirm the syntax is correct etc.

-br

49  Using Arduino / Programming Questions / Re: How to pass variable to library? on: May 08, 2013, 08:28:08 am
You also need to declare your new variable in the library's .h file.

As Paul says, you are trying to accomplish A and asking us about C.  It would be nice to know A and B.

-br
50  Using Arduino / Programming Questions / Re: How to pass variable to library? on: May 08, 2013, 06:53:45 am
The library can't see your sketch's globals.  That's why you get the error.

You can add a global to the library, which then your function can see.

Or you could add an additional argument to a library function and pass the boolean in that way.

-br
51  Using Arduino / Programming Questions / Re: A quick question about delay... on: May 07, 2013, 08:18:59 pm
Without the delay, your analogWrite stays in play for only a few microseconds at most before your digitalWrite shuts off the LED.  Way too fast to have any visible effect.

With the delay, you have the analogWrite engaged for many pwm cycles, which conveys the proper visual effect.

-br
52  Using Arduino / Programming Questions / Re: Random messages in serial monitor on: May 07, 2013, 05:06:40 pm
This is very creative, but it's not your grand-daddy's C:
Code:
  Serial.println(receiverRight + "" + receiverLeft);
Try printing the ints separately with a blank between them.

-br
53  Using Arduino / Programming Questions / Re: Can't send a file through sd card to serial port. on: May 07, 2013, 02:45:03 pm
The number 1 when sent through the serial monitor is actually the ascii character '1', which has the value of 49 .

Test for '1', not 1.

-br
54  Using Arduino / Project Guidance / Re: please help me im going crazy. on: May 07, 2013, 11:01:37 am
Is this the line before the first error?
Code:
char keypad.addEventListener(keypadEvent); //add an event listener for this keypad

What is the purpose of that 'char' there?

-br
55  Using Arduino / LEDs and Multiplexing / Re: blink-without-delay slowing things by factor 10 ? on: May 06, 2013, 06:54:32 pm
Wondering: Did you really intend to use micros() here?

Code:
   unsigned long currentMillis = micros();   

-br
56  Using Arduino / Project Guidance / Re: How to pass char arrays to methods on: May 06, 2013, 03:33:12 pm
This code passes a char array to the Serial.println function:
Code:
char foo[] = "Hello, world!"
Serial.println(foo);

What are you trying to do, and what is the problem?

-br
57  Using Arduino / Project Guidance / Re: Serial.read more than letter on: May 06, 2013, 12:19:00 pm
C array indexes start at zero.  Your c[3] array has three elements numbered [0], [1], and [2].

-br


Moderator edit:Smileys disabled
58  Using Arduino / Programming Questions / Re: How to flush serial.read() receiver buffer, on: May 06, 2013, 07:36:31 am
This is a frequently asked question.  Clearing the input buffer is simple to do, but it is never a good design choice.

Quote
I can not figure out how to keep extraneous characters out of the buffer I an reading the string to.

There are two approaches that work: 1. Don't send them.  Or, 2. Consume them properly as they are sent.

Needing to clear the buffer is a sure sign of a design issue elsewhere, which we can help you with if you post your code (in code tags, please).

Good luck with your project,

-br
59  Using Arduino / Project Guidance / Re: Newbie needing help on: May 06, 2013, 07:01:27 am
Quote
code just looks like a mine field for at the moment
I'm sure it does, and this is exactly the point.  Part of the learning is training your eyes to spot the patterns in the code.  (Which is why reading poorly formatted code is painful to an experienced coder with code-friendly eyes.)

Find a good tough piece of code and read it every day for a few days and you'll understand much more of it.  Dig in on the parts you don't get and they will yield to effort.  (And if you have a specific question you can always ask it here - the forum is optimized for that.)

Cheers,

-br
60  Using Arduino / Project Guidance / Re: Newbie needing help on: May 06, 2013, 06:28:29 am
In my view, the best way to learn fast is to read a lot of other people's code.  You won't necessarily understand it all, at first, but that's good, and easily fixed with google.

You can find a lot of code here on the forum and playground, and don't overlook GitHub where some of the bigger projects live.

Just my two cents.  Good luck with your learning process.

-br

Pages: 1 2 3 [4] 5 6 ... 67