Show Posts
Pages: 1 ... 2318 2319 [2320] 2321 2322 ... 3354
34786  Using Arduino / Interfacing w/ Software on the Computer / Re: Java IDE and Adruino communication problem on: November 04, 2011, 04:30:37 pm
Quote
however when the board starts up digital O/P 13 comes on and stays on without a reset, im using it to drive a relay in my application and on at start up is undisirable.
Pin 13 has the onboard LED. It may be set to OUTPUT by default, rather than INPUT like the other pins.

Quote
I have written into the code to send 0 output to pin 13 after configuring the port in set up, i expect to get my knuckles cracked for not doing things properly but it works...
That is the proper way of setting the pin state and mode to the way you want it. No knuckle rapping in your future. Not over this, anyway.
34787  Using Arduino / Programming Questions / Re: power sucking code on: November 04, 2011, 04:25:28 pm
Code:
int relayPin[] = {10};
A one element array? Why?

Quote
I connected an LED to the output pin, that dimly glows, and my multimeter doesn't read anything (it's quite cheap though).
Would that be pin 10? Do you know that pin 10 is HIGH when you perform this reading? Do you have a current limiting resistor with that LED, or have you burnt out the pin?
34788  Using Arduino / Programming Questions / Re: micros() resetting intermitantly (timer2 being used) on: November 04, 2011, 04:13:25 pm
So i guess when an ISR triggers it basically pauses the code just long enough to run the ISR code, right?
Yes. The problem, as you can see, comes when the code does not finish before another interrupt occurs.
34789  Using Arduino / Programming Questions / Re: Help with arrays and code simplification on: November 04, 2011, 03:56:45 pm
The point about using functions was to get you to start developing and using them. For instance, you read data from the ping sensor. That is not a single step operation. Put all that code in a function, ping() that returns a distance.

Code:
  if (cm < 122 && cm > 76){
I find this code hard to read.
Code:
if(cm > 76 && cm < 122)
performs the same check, with no head scratching to understand it.

Code:
  else if (cm < 76 && cm > 46){
This test will not be reached unless cm is less than (or equal) 76, so the first test is not needed. Less code is nearly always better.

Boundary conditions should abut, not be separated. If cm IS 76, the first test is not true, and neither is the second test. One of them should be, unless 76 has some specific, non-obvious meaning. If it does, and there is a reason that nothing happens at that specific value, there should be some comments that explain why not.

Quote
    // I want the code to be able to go in reverse order
    // and also to not get stuck in a while loop
Then a while loop is almost certainly not what you want to be using.
34790  Using Arduino / Programming Questions / Re: Communicate between Xbee and LabView? on: November 04, 2011, 03:41:21 pm
Quote
Isan't xbee the communicator between the computer and the arduino?
An XBee is a radio. You need one at the PC end to. The PC is NOT a radio. At least not one that can receive XBee frequency transmissions.

As was mentioned, you left out an awful lot of details.
34791  Using Arduino / Programming Questions / Re: help with arduino and c# on: November 04, 2011, 03:32:06 pm
The Arduino needs to send data to the C# application, via the serial port, using Serial.print(), Serial.println(), and/or Serial,write(). This should be done when the Arduino determines that something of interest, like a switch being pressed, has happened.

The C# application needs to have a callback registered that gets invoked when the Arduino sends serial data. That callback needs to read the serial data, and determine the correct action. Then, it needs to perform that action.

The user interface processing in a C# application usually runs in one thread, and the serial processing in another thread. The serial processing thread can not directly modify the user interface. It needs to Invoke() (that's a hint) a method in the user interface thread to perform the user interface change.
34792  Using Arduino / Programming Questions / Re: Efficiency of multiple If conditions on: November 04, 2011, 03:26:45 pm
Quote
Efficient, but can be a little surprising.
Especially if the if test involves a function call, and you expect that function call to be made.
34793  Using Arduino / Programming Questions / Re: Getting library errors from my code. on: November 04, 2011, 03:24:59 pm
Quote
line_audit_case:55: error: 'class File' has no member named 'writeError'
How much more descriptive can an error message get? If a class has a method, you can call that method. If it doesn't, you can't. Wishing you could won't change a thing.

Quote
line_audit_case:55: error: 'class File' has no member named 'sync'
Ditto.

Quote
line_audit_case:106: error: 'class TwoWire' has no member named 'recieve'
Ditto.

The rest of the errors are the same kind. Look at the classes being referenced in the errors. Look at the methods available. Only call those methods.
34794  Using Arduino / Programming Questions / Re: Help please, how do you send data on API mode on Xbee series 1? on: November 04, 2011, 03:08:48 pm
There is a library, XBee, that builds the frames for you. Is there some reason not to use it?
34795  Using Arduino / Programming Questions / Re: micros() resetting intermitantly (timer2 being used) on: November 04, 2011, 09:43:04 am
You're sitting at home, reading a book. The doorbell rings. You can go answer the door, and invite the person in, or you can talk to them in the doorway.

If you invite them in, you can deal with the doorbell if it rings again.

If you stand there in the doorway dealing with them, and someone else arrives and rings the doorbell, you are kind of stuck.

The serial printing you are doing in the ISR is like dealing with the person in the doorway.

Setting a flag, telling loop it needs to do something, is like inviting them in. You still have to deal with them, but not necessarily before the next person/interrupt arrives.
34796  Using Arduino / Programming Questions / Re: Communicate between Xbee and LabView? on: November 04, 2011, 09:37:31 am
So, what is the XBee doing?
34797  Using Arduino / Programming Questions / Re: Temperature sensor with multiple 74HC4511's and 7 segments. on: November 03, 2011, 02:37:45 pm
Quote
But I can not figure out how to e.g make the first 7-segment write "2" when the temperature is 20-29, and "30" if the temperature is in the 30's.
What code do you have to display anything on the displays?
34798  Using Arduino / Interfacing w/ Software on the Computer / Re: Java IDE and Adruino communication problem on: November 03, 2011, 02:33:55 pm
Quote
Is there a way round having to manually reset the Adruino mega after starting serial communication with the board.
Unless you have modified the Arduino, opening the serial port from a PC application does reset the Arduino.

Quote
when my project is completed i wont have access to the board as it will be in a remote location, so this is going to be an issue.
But still connected to a PC?

Quote
can someone please provide a quick fix example that will work by either responding to a command from a PC or internally in the setup code.
What you are describing is not normal behavior. Until the sketch is running, any code in setup() won't be executed, including connecting to the serial port to receive a command. So, no, code won't help you.
34799  Using Arduino / Programming Questions / Re: OneWire and DallasTemperature libraries under 1.0 beta on: November 03, 2011, 02:26:08 pm
Replace the #include "WConstants.h" with #include "Arduino.h" in OneWire.cpp.
34800  Using Arduino / Programming Questions / Re: Code Problem- Two motors need to work at once in simple sketch on: November 03, 2011, 01:02:48 pm
Code:
for(pos1 = v2; pos1 < 179; pos1 += 1)  {   
   
   v2 = random(30,180);           
   servo1.write(pos1);             
   delay(50);                     
 }
Probably work better if you assigned a value to v2 BEFORE using it in the for loop.

You have one loop to move each servo. The 2nd servo doesn't start until the 1st one completes its motion.

Use just one loop, moving both servos in that loop.
Pages: 1 ... 2318 2319 [2320] 2321 2322 ... 3354