Show Posts
Pages: 1 ... 327 328 [329] 330 331 ... 844
4921  Using Arduino / Project Guidance / Re: This little light of mine on: September 02, 2013, 09:03:52 am
Presumably the buoy needs to have a substantial power supply to power the lamp, so the small additional drain of some electronics might not be a big issue. If it is, would there be any chance of adding a solar panel? I'm imagining something similar to those cheap solar powered garden lamps.

You could reduce the receiver power consumption by having the receiver power down for e.g. ten seconds at a time, and then arrange that the transmitter transmits continuously on approach - the receiver should pick up the signal within a few seconds when it is range.
4922  Using Arduino / Project Guidance / Re: A little math help.... on: September 02, 2013, 08:59:08 am
I used the Pythagorean Theorem to get all side lengths.

That would only be valid if you knew that this was a right angled triangle, which I don't think is the case here.

You can work this out using Pythagoras' theorem if you divide one of the sides to produce TWO right angled triangles and then solve those as simultaneous equations.
4923  Using Arduino / Programming Questions / Re: equaling two pins. on: September 01, 2013, 06:15:40 pm
in a condition i want to connect boards input and output.
i mean i want to equal two pins.
how can i achieve this ? smiley-slim smiley-slim smiley-slim

Just connect the output directly to the input, avoiding the Arduino completely? Writing a sketch that emulates a bit of wire seems rather pointless.
4924  Using Arduino / Programming Questions / Re: Writting my own timer interrupt library - can you pass a reference to a function on: September 01, 2013, 06:13:51 pm
     if(currentTime >= (loopTime + 1000)){ 

As an aside, this is not a good way to do timer arithmetic since it does not handle overflow conditions well. It's best to ensure that you hold time values as unsigned long variables, and then use subtraction rather than addition. Logically the results are the same if you ignore the limitations of the data types, but in practice this approach works correctly when timer values overflow.

Also, just as a detail, in order to maintain an accurate frequency and avoid slippage, it's best to increment the time by the interval rather than assume that the next period starts 'now'.

Code:
if(currentTime - lastTime <= interval)
{
    lastTime += interval;
   doStuff();
}
4925  Using Arduino / Project Guidance / Re: Rx unique byte to turn on specific LED patterns on: September 01, 2013, 06:04:54 pm
The bytes coming in will be miidi program change messages.

Oh, OK. I assume that defining the supported commands would be a one-time activity and you aren't too concerned about how much effort it takes.

That being the case, it would be reasonable IMO to store the mapping (from the MIDI input byte to the output states) in EEPROM. If I were you then rather than using input buttons etc to perform the programming, it would be easier to just provide a command line that let you type the byte value and the corresponding output states in via the serial monitor or whatever other serial client you wanted. It would be quite simple to implement a sketch that let you type in 'SET 55 01001010' for example to define the output states corresponding to input value (decimal) 55. If you implement this approach there is no reason to limit the number of output states to eight, and if you think there is any likelihood that you will want to support more than eight outputs I'd start now by holding the output states as a 16-bit or 32-bit int.
4926  Using Arduino / Project Guidance / Re: sending AT commands to receive sms on: September 01, 2013, 05:57:16 pm
There seem to be two issues - getting the modem working at all, and designing a real sketch to use it.

Just to get it working at all, using delays to ensure that the whole response is available before you start reading it would probably work, but I'd want to know how big the expected responses were and confirm that the SoftwareSerial receive buffer was big enough to hold them. At the very least, I suggest you should empty the receive buffer after each command.

In your code to check for newline characters you are testing for '/n'. You should be testing for '\n'. I don't think this will solve all of your problems, but you might as well get it right.

The garbage you're seeing on the Serial output makes me suspect that the modem SoftwareSerial port settings are not correct. What speed does the modem default to?

In the full sketch I suggest you should work out when you have received a complete response based on what you have received rather than based on a fixed delay, but you aren't at the point where matters yet.
4927  Using Arduino / Programming Questions / Re: Use Array to Blink More Than One Pin on: August 31, 2013, 08:16:27 pm
When you pass an array as a function argument, what actually gets passed is a pointer. The compiler has no knowledge of the length of the array - in fact, you could call it twice with different length arrays so obviously the length cannot be fixed at compilation time. Hence the sizeof() calculation on your code is not actually calculating the number of elements in your array. What it is actually doing is dividing the size of a pointer by the size of an int. On most Arduino platforms, the result will be one.

If you want arrayWrite() to support arbitrary-sized arrays, add an argument to specify the length of the array being passed in. You can calculate this length in loop() using a similar sizeof(array)/sizeof(array[0]) calculation if you like - it will work OK here since you're referring to the array variable directly and not as a formal parameter.

Also, the <= constraint in your for loop should be a <, otherwise, you will execute the loop one time too many (i.e. twice, when your sizeof() calculation indicated that the array length was one).
4928  Using Arduino / Project Guidance / Re: Hydroponics Project on: August 31, 2013, 07:28:55 pm
I remember reading about a very active open source community working on residential hydroponics systems, and if you haven't already found them I suggest you go take a look for them. They could potentially save you from a lot of trial and error and bypass a lot of your development work.
4929  Using Arduino / Programming Questions / Re: Help with code, please.. on: August 31, 2013, 07:01:28 pm
Thanks to all for your help, but, now I am really confused...

Look at the State Change Example example sketch. It demonstrates how to do what you're trying to do.
4930  Using Arduino / Programming Questions / Re: Potentiometer with Processing does not update value [images included] on: August 31, 2013, 06:59:42 pm
You only read one byte each time draw() is called, and it probably isn't called very often. If you replace that 'if' with a 'while' then it would consume all available serial input each time draw() was called. That might still mean there is some latency while you want for draw() to be called, but it would avoid having that potentially large backlog of unread serial input pending in the serial buffer that you have to wade through before you reach the updated data.
4931  Using Arduino / Programming Questions / Re: Error message while compiling the code to send the captured image to android phn on: August 31, 2013, 06:56:08 pm
sketch_aug31a:126: error: initializer expression list treated as compound expression

sketch_aug31a:126: error: 'messageChar' was not declared in this scope

Both error messages relate to messageChar(), which you call but don't declare or define anywhere in the code you have posted. What is this function?
4932  Using Arduino / Project Guidance / Re: sending AT commands to receive sms on: August 31, 2013, 06:47:22 pm
despite using Serial.write() as opposed to Serial.print(),the characters appearing on the serial monitor are mainly numbers or symbols :-/.

Code:
               Serial.print(incomingByte);
               Serial.println(incomingByte);

I'm not seeing the Serial.write() in your code.

Also, you haven't addressed the issue of waiting until you receive a complete response to a command before you send the next command.
4933  Using Arduino / Programming Questions / Re: Help with code, please.. on: August 31, 2013, 08:51:43 am
What I would like to achieve is: when light is detected a relay turns on for 4 secs then turns off and the same when dark is detected.

Do you mean when it changes from light to dark it operates one output for four seconds, and when it changes from dark to light it operates another relay for four seconds?

If so, you need to remember what the previous state is so you can tell when it has changed. The StateChangeDetection example sketch shows you how this can be achieved.
4934  Using Arduino / Programming Questions / Re: PWM pump speed control on: August 31, 2013, 08:25:44 am
Could this work?

The feedback algorithm you describe might work - depends on the characteristics of the system you're trying to control. Give it a go and see what happens.

I don't see any need for loops in your code. Remember that the loop() function is called repeatedly so you can just put your recurring logic here. In pseudo-code, the algorithm you describe could be implemented like this:

loop:

measure temperature difference
if temperature difference too high and pump speed less than 100%, increase pump speed a bit
if temperature difference too low and pump speed more than 0%, decrease pump speed a bit
wait to allow the system to respond
4935  Using Arduino / Project Guidance / Re: Rx unique byte to turn on specific LED patterns on: August 31, 2013, 08:13:21 am
Sounds pretty labour-intensive for the poor old end user. Where do these one-byte commands come from?
Pages: 1 ... 327 328 [329] 330 331 ... 844