Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Nested If/Else on: February 09, 2013, 11:57:09 am
I am trying to understand the relationship of the open and closing brackets when using nested IF/ELSE statements.  I cannot seem to grasp the concept of exactly when a complete IF/ELSE statement ends.  In other languages like COBOL, END-IF marks the end of each IF/ELSE statements in the nest and finally, a period ("."), marks the end of the entire nested IF/ELSE logical argument.  I believe my current program is failing because of misplaced brackets - although the program verifies, of course.  I've searched many on-line reference but what's needed is a way to look at a flowchart in relation to the code.  

So, I have included a link below to a .PDF of a flowchart I did this morning using SmartDraw.  It has three nested levels.  Although there are probably better ways of managing nested IF/ELSE arguments, like a case statement, I really need to understand the open and closing bracket relationship before I can move forward.  Anyone care to reply with the code to match the flowchart in the link?  Many thanks in advance!

http://tinyurl.com/b7n6mdp

Here's my shot at it.  Right now, I'm just focused on the "{ }" brackets and not the Arduino commands:

If X {
  If Y {
    If Z {
      do D
    }
    Else {
      do C
    }
   }
   Else {
     do B
   }
  }
 Else {
   do A
  }
}


-Paul
2  Using Arduino / Programming Questions / Re: Simultaneous Funtion/One-Shot Emulation on: January 12, 2013, 11:14:58 am
Quote
It's odd that the command does not appear in my Arduino programming book.
Which one would that be?

Monk, S., Programming Arduino - Getting Started with Sketches, ISBN 978-0-07-178422-1

Paul
3  Using Arduino / Programming Questions / Re: Simultaneous Funtion/One-Shot Emulation on: January 12, 2013, 10:53:56 am
Read and understand the Blink Without Delay example, then you will see how to program the Arduino to do several things at once.

dc42 & Chaul,

Thanks for your responses.  The "Blink without Delay" command should do the trick.  It's odd that the command does not appear in my Arduino programming book.

Paul
4  Using Arduino / Programming Questions / Simultaneous Funtion/One-Shot Emulation on: January 12, 2013, 09:39:41 am
Here's my dilemma:

I've written a program to quickly switch between receive and transmit states in a communications system.  The microprocessor is the Arduino Nano.  All is well until I want to pulse an LED as a one-shot for one second while the program continues to execute.  The LED will be used a visual fault indication, pulsed just long enough to show a system timing error.  And since this is a timing program with adjustable parameters changed in 1 msec increments, I cannot simply wait one second for the LED to turn off, then resume processing. 

What I want is (logically) simple: the ability to pulse an LED when an input pin changes state and stay that way for one second, while the program continues to execute.  Surely there must be some way of handling this with the Arduno microcontroller?

Ideas?  Thanks!

Paul 
Pages: [1]