Show Posts
Pages: 1 ... 42 43 [44] 45 46 ... 290
646  Using Arduino / Project Guidance / Re: Want to convert some ray data to required format on: May 18, 2014, 01:51:18 am
What has this got to do with the Arduino ?
What exactly do you want the result to look like.  Can you give an example ?
15 bits to 77 bits ?  How ?
647  Using Arduino / Programming Questions / Re: Need help with code. on: May 17, 2014, 11:34:57 am
Code:
       previous = reading;
This is in the wrong place, and what about the previous readings of the other two inputs ?

I see that you did not follow my advice to name the variables with a 0, 1 or 2 at the end.  You can make the program work by using two and three but using 0, 1 and 2 makes the change to using arrays to hold the variables much more obvious.
648  Using Arduino / Programming Questions / Re: Need help with code. on: May 17, 2014, 08:53:47 am
Thank you.  Much easier to access.

The obvious way to do what you want is to repeat the code 3 times using different variables for each button/LED combination.  Start by using the code that you have and renaming all the variables with a zero on the end, such as state0, inPin0 etc.  Make sure that the code works.  Now add a second set of variables with the same names but with a 1 on the end, such as state1, inPin1 etc and separate code to read and handle the input and timing.  Make sure that the code works.  Now add a third set of variables etc with a 2 at the end of the names and make sure that it works.

By now you will have lots of lines of code with similar variable names all doing the same thing.  There must be a better way, and there is.  Read up on arrays.  Declare all your variables as arrays with 3 levels.  This way you will have state[0], state[1] and state[2] etc.  Now put one set of the code that reads inputs and deals with outputs into a for loop that runs from 0 to 2 and accesses the array variables using the for loop variable.  Now you have a much smaller program and have learned about arrays and for loops.
649  Using Arduino / Programming Questions / Re: Need help with code. on: May 17, 2014, 08:23:29 am
Quote
The code is in the pastebin link
I will look at it when you post it here.
650  Using Arduino / Programming Questions / Re: Timer problem on: May 17, 2014, 04:54:05 am
Code:
    while (millis() - timeToCheck < 1000);
Because of the semi-colon your program will execute this while loop for one second during which it will do nothing else.   

You need to check whether the button is pressed within the while loop and take action as appropriate.
651  Using Arduino / Programming Questions / Re: Timer problem on: May 17, 2014, 04:18:25 am
Quote
Any suggestion ?
Yes.  Post you whole program
652  Using Arduino / Programming Questions / Re: 2 PID´s connected in series!! on: May 17, 2014, 01:41:18 am
hello I am trying to make a control algorithm that takes the output of a PID makes a few calculations and them introduces that value as a Input of another PID. The problem is that the second PID outputs a NAN value.

Is there a way to solve this problem?
Is it even possible to do what I want whith the PID library?

thanks!
I assume that NAN means Not  A Number.
Post your code for comment and help as it is impossible without it and we cannot for instance see how the 2 PIDs are defined and used.

As to the general principle, a PID doesn't care about the source of its data as long as it is the correct type.  It is, after all, just a computer program.  What is it that requires 2 PIDs in series ?
653  Using Arduino / Project Guidance / Re: LCD to monitor a potentiometer's state on: May 16, 2014, 01:17:01 am
http://arduino.cc/en/Tutorial/LiquidCrystal
654  Using Arduino / Programming Questions / Re: More efficient comparisons of temp differentials to control heater on: May 15, 2014, 12:49:10 pm
Remove all delay()s from your program,  change to the principle shown in the BlinkWithoutDelay example in the IDE and refactor the code to make it into a state machine.

When in each state where you need a 'delay' use the BWD principle.  Save the value of millis() when the system enters the state then check each time through loop() check whether the required period has elapsed and act on it, probably by changing state.  If not then do other things such as reading inputs and act on them.
655  Using Arduino / Programming Questions / Re: RC Car using NRF24L01 , L293D with DC Motor on: May 15, 2014, 11:13:29 am
You know when the network is available and read the data into the message variable and act on it.  That must mean that you know when the network is not available, so when that happens set the message variable to something that is not one of your car commands.
656  Using Arduino / Programming Questions / Re: RC Car using NRF24L01 , L293D with DC Motor on: May 15, 2014, 09:55:56 am
Quote
when there is no input from TX, motor connected in RX UNO should stop, but it is not stopping
What does the message variable contain when the connection drops ?  Try setting it to a value that does not make the motors run when that happens.
657  Using Arduino / Programming Questions / Re: problem with Simple Timer program on: May 15, 2014, 04:56:27 am
Instead of connecting the external supply to Vin can you try connecting to the barrel connector ?  It shouldn't make any difference but you never know.

The problem only happens when you use the relay.  You have still not provided a link to it or details of its current consumption.

658  Using Arduino / Programming Questions / Re: Comparing Two Strings and char array referencing on: May 15, 2014, 01:48:39 am
Firstly, why not start with i = 0 ?  It would be much neater

Secondly
Code:
i=i++;
Very odd, to say the least.  Either you are setting i equal to some value or incrementing the value of i.  Which is it ?  Why not just
Code:
i++;

Thirdly, you are using Strings for the card IDs and a string for test_tag.  You need to make your mind up one way or the other and preferably use strings (note the lowercase s) for all of them.  Then you can use strcmp() to compare them.
659  Using Arduino / Programming Questions / Re: LiquidCrystal lcd(...) functionality on: May 15, 2014, 01:27:02 am
That looks like a dead end then.
660  Using Arduino / Programming Questions / Re: LiquidCrystal lcd(...) functionality on: May 14, 2014, 04:49:27 pm
Set a boolean variable, let's call it lcdDone, to false.  Test lcdDone before creating the instance.  Create the instance if lcdDone is false and set lcdDone to true.  Next time through loop() lcdDone will be true and a new instance will not be created.
Pages: 1 ... 42 43 [44] 45 46 ... 290