Show Posts
Pages: [1] 2 3 ... 3343
1  Using Arduino / Programming Questions / Re: Checking multiple variables for "states" and then lighting an led based on state on: September 17, 2014, 06:53:09 pm
Right, but if i made it just "led pin" you might loose that it was related to the buttons, i thought.
So, how about pinForLedAtSwitch?
2  Using Arduino / Programming Questions / Re: Checking multiple variables for "states" and then lighting an led based on state on: September 17, 2014, 06:50:04 pm
Quote
Also, i changed it from "buttonPin" to "buttonLEDpin"
The LED portion of the device is connected to one pin, and the switch portion is connected to a different pin, right?

So, the fact that the LED and switch are in the same physical container is immaterial, isn't it? The name is better, but it is still confusing.
3  Using Arduino / Programming Questions / Re: is it possible to use variables when calling functions? on: September 17, 2014, 06:45:52 pm
Quote
I think the code you sent me cycles through all the writeArduinoOnMatrix functions (I knew I should have given it a shorter name) one after the other. I want it to stay on one function.
It was only an example to illustrate how to call the 4 different functions by index number. Call them however you need to.
4  Using Arduino / Networking, Protocols, and Devices / Re: Arduino UNO + Ethernet Shield + RC522 connexion failed to Xampp server on: September 17, 2014, 06:42:57 pm
I'm missing something. You say that you are invoking the obtienevalor.php script at  http://elrecreo.cl/arduino/prueba1/, but your code says:
Code:
    client.println("GET arduino/tutoiot/iot.php?valor=1234567 HTTP/1.1");
on host:
Code:
    client.println("Host: www.elrecreo.cl");   

So, which is it?

The only name = value pair being passed to that script is valor = 1234567, but you say that you are looking for the value associated with the name idcard. Seems to me that it's no wonder it can't find the value.
5  Using Arduino / Interfacing w/ Software on the Computer / Re: Ethernet + SD + Ajax + IR on: September 17, 2014, 06:36:52 pm
Code:
                        if (webFile) {
                            while(webFile.available()) {
                                client.write(webFile.read()); // send web page to client
                            }
                            webFile.close();
                        }
This is crap. This will REALLY slow your page transfer down. Do NOT call client.write() with the ONE character that webFile.read() read.

The read() method is overloaded to fill an array, and return the number of bytes read. The write() method is overloaded to write an array of bytes, given a length. Make us of that to stop sending 512 byte packets containing 1 byte of payload.

Each file that you open requires a 512 byte buffer. You only have 4 times that much SRAM. Between the SD card buffers, all the string literals that are not wrapped in the F() macro, and pissing away resources on the String class, you just might be running out of memory.
6  Using Arduino / Programming Questions / Re: Checking multiple variables for "states" and then lighting an led based on state on: September 17, 2014, 06:28:46 pm
Quote
ok, I *think* i've made the button array pins an output.  At least, the LEDs are bright now.
I don't understand why the LEDs are connected to pins defined in the buttonPin array. Why is the name NOT ledPin?
7  Using Arduino / Programming Questions / Re: Aquarium LEDs and fading on: September 17, 2014, 06:26:41 pm
What is really needed is one flag to indicate that sunrise fading should be happening and another to indicate that that flag has already been set to true. It is the second flag that should start out false, have the not operator in front of it, and be involved in the first if test.

You don't want to start fading over and over again while the hour and minute values match.

Alternatively, you could involves seconds in the if statement (seconds == 0), and add a delay(1000) in the body of the first if statement. Not that I like that approach, but it makes for an easy test.
8  Using Arduino / Programming Questions / Re: is it possible to use variables when calling functions? on: September 17, 2014, 05:48:44 pm
This is at least the third time this week that a very similar question has been asked. The short answer is no. The long answer is function pointers in an array, and call the function at the appropriate index position, by pointer.
9  Using Arduino / Programming Questions / Re: Checking multiple variables for "states" and then lighting an led based on state on: September 17, 2014, 05:39:18 pm
Quote
I'm going to try to add it some comments, then see what i can do about making these outputs...
Perhaps the reverse order would make more sense. On the other hand, making switch pins OUTPUT doesn't make sense. Perhaps making the pins OUTPUT and the array name more meaningful would.
10  Using Arduino / Programming Questions / Re: Aquarium LEDs and fading on: September 17, 2014, 05:36:57 pm
Code:
  if ((hour >= sunRiseHour) && (minute >= sunRiseMin) && !sunRiseFading)
  {
     sunRiseFading = true;
     lastChange = 0;
     fadeUp = 0;
  }
Did this happen at the right time? Serial.print("It's sunrise!"); in the block to KNOW.

Code:
  if ((hour > dayHour) && (minute > dayMin) && sunRiseFading)
  {
     sunRiseFading = false;
     lastChange = 0;
  }
Did this happen at the right time?

Code:
   if(now - lastChange > 100)
   {
      fadeUp ++;
      fadeUp = constrain(fadeUp, 0, 255);
      analogWrite(rLEDpin, fadeUp);
      analogWrite(bLEDpin, 0);
      analogWrite(gLEDpin, 0);
      lastChange = now;
   
  }
Same question. Does this happen only every 10th of a second? By the way, this will ramp the LED up in 2.5 seconds, not the two minutes you allocated for sunrise.
11  Using Arduino / Programming Questions / Re: Time and TimeAlarms Libraries – Ask here for help or suggestions on: September 17, 2014, 05:30:48 pm
Quote
And then everything goes haywire when your start program is at 22 hours and stop program is at 3 in the morning, and the reset happens in between.
I don't see why. You know something needs to start at some time. If it is that time, start it.
You know something needs to end at some time. If it is that time, stop it.

I think your problem is that you are thinking in terms of "it needs to start at x:xx and end at x:xx, and be called over and over again in between.

That's not the best way to do that. Think in terns of setting a thisProcessShoudlBeRunning flag to true if it is 9:00PM. Set it to false if it is 3:00AM.

Then, independent of the time, test the flag to see if the process should be running.
12  Using Arduino / Programming Questions / Re: Checking multiple variables for "states" and then lighting an led based on state on: September 17, 2014, 05:24:23 pm
Your code seriously needs commenting. For instance:
Code:
    if (buttonArray[n] == 0) {
       digitalWrite(buttonPin[n], LOW);
       Serial.print("Hello1");
    }
   
    if (buttonArray[n] == 1) {
       digitalWrite(buttonPin[n], HIGH);
       Serial.print("Hello2");
    }
The name suggests that buttonPin is an array of pins that have switches attached. There is no use of the array in setup(), where pinMode() is called, so the pins default to INPUT, so, here you are turning the internal pullup resistor off and on. Why this is useful should be explained in some comments.

Or, maybe you just need to fix the code... smiley-cool

13  Using Arduino / Programming Questions / Re: Aquarium LEDs and fading on: September 17, 2014, 05:12:13 pm
Quote
So do we need to restrict the pwmlnit value to a max of 255?
Wouldn't hurt, but it shouldn't be necessary.

The comments are correct.

Quote
I guess i could also set the interval as daylight time - sunrise time (in millis)?
You could. That would let you change the length of time the fading takes without hard-coding anything.
14  Using Arduino / Programming Questions / Re: VirtualWire and variables on: September 17, 2014, 05:08:30 pm
Quote
Why are you using char and a "*" here when you aren't using it here:
For the same reason you don't do this:

Code:
int a = 14;
int a = 22;

char * is a type. It defines the size of, and allocates space for, a variable that can hold a pointer to a char (array).
15  Using Arduino / Programming Questions / Re: serialEvent() string reconstruction and interpreting issue. on: September 17, 2014, 05:02:34 pm
Code:
while (Serial.available() > 0) {
    charsRead = Serial.readBytesUntil('\n', message, MESSAGESIZE);
    message[charsRead] = '\0';   // Make it a string...
    commandComplete = true;
}
while?
Pages: [1] 2 3 ... 3343