Show Posts
Pages: 1 2 [3] 4 5 ... 230
31  Using Arduino / Programming Questions / Re: break; not working in while(1) loop on: September 15, 2014, 05:17:52 pm
Get rid of all the commented out code, put curly braces on separate lines and use the Arduino IDE's auto format tool to fix the indenting. You don't want people who can help you taking one look at it and thinking "the hell with this, I'm not weeding through that code."
32  Using Arduino / Project Guidance / Re: xbee address on: September 15, 2014, 02:52:31 pm
You'll have to send it yourself in the code and devise some sort of protocol to differentiate between the address and the data
33  Using Arduino / Programming Questions / Re: Looking for general code to read from Serial port and return char* on: September 14, 2014, 10:48:07 am
Pauls so I do need to read everything at once, as processing it individually will ruin the struct.

That's simply not true. You can read them seperately, then only process the data when you receive something that indicates there is no more data.

Is there any way like if I get a global variable to always use and always return the pointer to that variable?

There is no point in returning a global variable, just return something to indicate if there is valid data in the global variable and the code outside of the function can utilize the global variable.
34  Using Arduino / Programming Questions / Re: Looking for general code to read from Serial port and return char* on: September 14, 2014, 10:28:05 am
http://gribblelab.org/CBootcamp/7_Memory_Stack_vs_Heap.html

Local variables in functions are pushed onto the stack. When you return from the function, they are popped off of the stack and the space is immediately available.
35  Using Arduino / Programming Questions / Re: Problems with is statement on: September 12, 2014, 11:06:02 am
gauss isn't unless it's under 1800. Once it equals or is greater than 1800, the variable is never updated, therefore the condition will fail. The only reason it works now is because it's initialized to 0. If you were to initialize it to 2000, it wouldn't work the first time.

Don't be afraid to litter your code with Serial.print statements to debug it. Printing the value of guass would have given you a clue as to the problem.
36  Using Arduino / Programming Questions / Re: Three node Zigbee network Programming in Arduino on: September 12, 2014, 11:02:27 am
Code:
int incomingByte; //a variable to read data
int add;// a variable to read identifier

void setup() {
  // initialize serial communication:
  Serial.begin(9600);
}

void loop() {
  
  // see if there's incoming serial data:
  if (Serial.available() > 1) {
    Serial.print("start");
    add=Serial.read();
//if identifier is 1,print the received data
    if (add=='1')
    {
      Serial.println("first node");
    incomingByte = Serial.read();
    Serial.write(incomingByte);
     }
}
}

Again:

Quote
You also don't read the second byte if the identifier doesn't match. That will cause it to get it off sync very fast.

Even if you were to read both regardless of if the identifier matches, a single missed digit and you're out of sync. I think you should re-think your strategy. State machines are the best way to handle this. You would send a "start packet" byte, then the identifier, then the value. If the length of the value could vary, you would want to also send a "stop packet" byte. The state machine would accept the incoming byte as its input and have states such as SEEKING_START_BYTE, SEEKING_IDENTIFIER and SEEKING_VALUE.

Quote
Is there any other way to communicate to serial monitor other than serial?

Not with a regular Arduino

Quote
How to communicate then with serial other than

Assuming you're using an Uno or other single UART device, you can use the SoftwareSerial library.
37  Using Arduino / Programming Questions / Re: Problems with is statement on: September 12, 2014, 10:54:09 am
Post the full code, or at least a small subset that still compiles and demonstrates the problem.
38  Using Arduino / Programming Questions / Re: I've gone as far as I can go, can't get multiplexing to work on: September 11, 2014, 07:03:06 pm
I thought thats what this was doing, changing the state of the pin.  Does this code:
Code:
int digits[4] = {
    D1, D2, D3, D4    };
  for(int i=0; i<4; i++){
    if(i != targetDigit){
      digits[i] = LOW;
not cycle through all 4 digits turning them off in secession expect for the digit that is called out as target digit?

No. digits is an array of pin numbers, not pin states. You have to use digitalWrite to change the state of a pin. This is a prime example of why PaulS made note of the fact that "digits" is not descriptive enough. It should be something like "digitPins", and that should make it more clear as to why assigning a state to a pin variable makes no sense.
39  Using Arduino / Programming Questions / Re: Three node Zigbee network Programming in Arduino on: September 11, 2014, 10:09:23 am
Hi Arrch,
Thanks for pointing out.I thought both represent numeral 1. I was wondering Why the control doesn't enter the loop.Now I get it.
So should the program at the receiver must be modified like this?

Code:
if (add=='1')
    {
      Serial.println("first node");
    incomingByte = Serial.read();
    Serial.write(incomingByte);
     }
I am beginner. So please pardon me if I am making some silly mistakes

There is no loop in what you posted, post your entire sketch. You also shouldn't be using Serial to communicate with both the serial monitor AND the other Arduino.
40  Using Arduino / Programming Questions / Re: pinMode vs' physical pin and integer value on: September 11, 2014, 12:10:50 am
Google poet manipulation. What you ate actually doing is setting or clearing a bit in a register. pinMode creates an attraction layer for the various chips.
41  Using Arduino / Programming Questions / Re: 3 condition with button, Help please on: September 11, 2014, 12:06:38 am
StateChangeDetection example shows you how to notice a button press. A variable to contain the state. And a switch statement to conditions based on the state.
42  Using Arduino / Programming Questions / Re: LED Color fade based on time of day on: September 10, 2014, 11:24:47 pm
Break your project into more manageable parts:

Get the LEDs to fade. Then, get the time of day to print. Then start combining the code. If you want people to help with specifics in the code, you'll need to post what code you have so far and describe the specific problem you're having.
43  Using Arduino / Programming Questions / Re: Programming Help. Dice game. on: September 10, 2014, 11:21:42 pm
Remove all the unnecessary white space that is a major distraction, and re-post your code.
44  Using Arduino / Project Guidance / Re: Push button timer and LCD readout sketch needed on: September 10, 2014, 11:18:45 pm
What kind of people are on this board with their holier than thou attitude if this is a board to help people, for free, not financial consideration?

I think you're missing a major key word there: help. People here are more than willing to help others. You didn't ask for help with the project you asked for someone to post code that does what you want, be it from an example or a sketch that they "whipped up" for you. Maybe that's your definition of help, but that's not the case around here. It looks like nobody has an example sketch that fits your needs. Since you're can't "write code", it looks like you're at an impasse.
45  Using Arduino / Programming Questions / Re: callback actions/functions? on: September 09, 2014, 11:13:53 am
Thanks.


In the above example I don't see anything that looks like s1->

What does that part of the menwiz code do?

-> is short hand for referencing a pointer and accessing a member variable. The code you're looking at has an object pointed to by "s1". The object it's point to has a member function "addVar"
Pages: 1 2 [3] 4 5 ... 230