Loading...
  Show Posts
Pages: 1 ... 20 21 [22] 23 24 ... 96
316  Using Arduino / Programming Questions / Re: bootloader delay on: April 15, 2013, 09:58:25 am
as accurate as possible.
i'm competing in a sumo bot competition and there is a five second delay before starting.
if i start too early i'm disqualified.
if i start a second late the other bot has a jump on me.
How accurately, and by what method, is the delay being measured in the competition ?
317  Using Arduino / Programming Questions / Re: Push button print text to LCD. on: April 15, 2013, 09:56:26 am
Only clear the display and output the text when the button state has changed.  That way the output only happens once, not every time through loop().
318  Using Arduino / Programming Questions / Re: Push button print text to LCD. on: April 15, 2013, 09:42:14 am
Quote
but my LCD text is still showing dual messages on the screen.
You are outputting text to 2 different lines on the LCD and not clearing the previous text.  Clear the LCD or just the previous text before printing the new text.
319  Using Arduino / Programming Questions / Re: Button Sequence help on: April 15, 2013, 09:17:26 am
The flowchart is a good start.  Looking at it I can see why you had a problem describing what you want to do.

What I would do next is to use the chart to break the sequence into a number of states that the program might be in.  For instance, waiting for the button 1 to be  pressed to start the sequence could be state 1, waiting for button 2 could be state 2, the first 2 second delay could be state 3 etc.  Then you write down what has to happen to get out of a state, such as pressing a button or a delay ending, and the state that the program should move to when the change happens.

Now, how to program it.
My suggestion would be to use switch/case with the switch variable being the state and the cases being the current states.  For each state, test for the action(s) required to exit the state, carry out the actions and change the state variable to the state you are moving to.  Put this in the loop() function and the program will continually monitor the state and look for actions being taken.

Incidentally, I can see some anomalies in your flowchart or maybe some explanation is needed.  After button 2 has been pressed near the start you have a test for whether button 2 has been pressed.  Is that a second press or the original one ?
320  Using Arduino / Programming Questions / Re: Can serial receive a byte and send it immediately? on: April 15, 2013, 05:40:01 am
Quote
Am I reading that right ?
I hope not, but it wouldn't be the first time I got some code wrong. Here it is with the comments I probably should have included

Code:
while (1) {  // do forever
     while (Serial1.available() < 1) {};    // wait for at least 1 character to become available
     Serial1.print(Serial1.read(), HEX);   // read and transmit the character
}

I also added the braces after the empty while busy loop, I normally do that to highlight that the loop does nothing.
______
Rob
Ah, that makes more sense and I can see that I was wrong
321  Using Arduino / Programming Questions / Re: bootloader delay on: April 15, 2013, 04:26:26 am
I wouldn't bother messing with the bootloader.  As has been suggested, start with delay(5000) at the end of setup(), turn on an LED at the end of the delay() and tweak the value to make the total startup delay exactly what you want.  How accurate does the 5 second delay have to be ?
322  Using Arduino / Programming Questions / Re: TASKS on: April 15, 2013, 04:16:58 am
Until next time .....
323  Using Arduino / Programming Questions / Re: Can serial receive a byte and send it immediately? on: April 15, 2013, 04:15:41 am
Code:
while (1) {
     while (Serial1.available() < 1);
     Serial1.print(Serial1.read(), HEX);
}
To me that reads 'All the time there is nothing in the Serial1 buffer read the character that isn't there and send it to Serial1 as HEX' and 'by the way, do that for ever'

Am I reading that right ?
324  Using Arduino / Programming Questions / Re: Issue with variable declaration on: April 15, 2013, 03:51:34 am
Please excuse the question as I don't have an Ethernet shield, but shouldn't the sn, gw and mydns variable have a value ?
325  Using Arduino / Programming Questions / Re: Handling interrupts properly when using multiple inputs on: April 15, 2013, 01:37:38 am
Calling the loop() function from inside an ISR seems a bizarre thing to do, as does doing 3 analogWrites which take a comparatively long time to execute.  The usual technique when using an ISR is for it to set a variable to indicate that it has been triggered and for the value of the variable to be acted upon in the main program. 

This is only possible if the delay() function is not used in the main program because this blocks execution of other code until the delay() is complete and your code is full of them.  Consider using millis() as a timer using the technique used in the BlinkWithoutDelay example program.
326  Using Arduino / Programming Questions / Re: push button and stepper control on: April 14, 2013, 04:23:14 pm
Code:
        toggle = !toggle;
What is the purpose of these lines ?
327  Using Arduino / Programming Questions / Re: servo (knob) on: April 14, 2013, 10:42:22 am
I have got some of these
http://www.firstmarkcontrols.com/s021g.htm
could I use this instead, I have notes it is a 5k though what do you think?
5K will be OK
328  Using Arduino / Programming Questions / Re: Array reverse/array stop help on: April 14, 2013, 10:39:39 am
Code:
  for (int thisPin = pinCount - 1; thisPin >= 0; thisPin -= 6); // reset thispin back to zero


Code:
thisPin = 0;
would be easier, don't you think ?

As to the buttons, where is the code that you have tried ?
329  Using Arduino / Programming Questions / Re: If First Char on: April 14, 2013, 07:50:41 am
You need to read the whole string from the serial port.  At the moment all you are reading is one int.

This would be a good read for you http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=11425&page=1
330  Using Arduino / Programming Questions / Re: servo (knob) on: April 14, 2013, 06:20:57 am
How is the pot wired ?
Pages: 1 ... 20 21 [22] 23 24 ... 96