````

Difference between Analog and Digital circuit


Analog Circuits

  1. These circuits operate on continuous-valued signals(commonly referred to as analog signals).                    
  2. Analog circuits are difficult to design since each component has to be placed by hand as automation techniques for designing these circuits fail to do the job efficiently.
  3. No conversion of input signals are required before processing i.e. input signal is analog, the circuit directly performs various logical operations and produces an analog output.
  4. The man power available to design analog circuits is very low, this results in long time to market the finished products.
  5. Analog circuits are mostly custom made and lack flexibility. 

Digital Circuits

  1. These circuits operate on signals that exist only at two levels i.e. 0's and 1's (binary number system).
  2. On the other hand digital circuits are easy to design since automation technique can be applied at various levels of circuit design. This involves minimum human interaction.
  3. In digital circuits, the input signals are converted from analog to digital form before it is processed, i.e. the digital circuit is capable of processing digital signals only, and produces output which is again converted back from digital to analog signals so that the output gives meaning full results that can be understood by humans.
  4. The available manpower to design digital circuits is significantly large compared to that of analog circuit designers.
  5. Digital circuits have a high degree of flexibility.

Arduino - Conditional Operator ? :

The conditional operator ? : is the only ternary operator in C.

? : conditional operator Syntax

expression1 ? expression2 : expression3
Expression1 is evaluated first. If its value is true, then expression2 is evaluated and expression3 is ignored. If expression1 is evaluated as false, then expression3 evaluates and expression2 is ignored. The result will be a value of either expression2 or expression3 depending upon which of them evaluates as True.
Conditional operator associates from right to left.
Example
/* Find max(a, b): */
max = ( a > b ) ? a : b;
/* Convert small letter to capital: */
/* (no parentheses are actually necessary) */
c = ( c >= 'a' && c <= 'z' ) ? ( c - 32 ) : c;

Arduino - switch case statement

Similar to the if statements, switch...case controls the flow of programs by allowing the programmers to specify different codes that should be executed in various conditions. In particular, a switch statement compares the value of a variable to the values specified in the case statements. When a case statement is found whose value matches that of the variable, the code in that case statement is run.
The break keyword makes the switch statement exit, and is typically used at the end of each case. Without a break statement, the switch statement will continue executing the following expressions ("falling-through") until a break, or the end of the switch statement is reached.

Arduino - If…else if …else statement

The if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement.
When using if...else if…else statements, keep in mind −
  • An if can have zero or one else statement and it must come after any else if's.
  • An if can have zero to many else if statements and they must come before the else.
  • Once an else if succeeds, none of the remaining else if or else statements will be tested.

if … else if …else Statements Syntax

if (expression_1) {
   Block of statements;
}

else if(expression_2) {
   Block of statements;
}
.
.
.

else {
   Block of statements;
}

if … else if … else Statement Execution Sequence

If Else If Else Statement

Example

/* Global variable definition */
int A = 5 ;
int B = 9 ;
int c = 15;

Void setup () {

}

Void loop () 
{
   /* check the boolean condition */
   if (A > B)
 /* if condition is true then execute the following statement*/
 {
      A++;
   }
   /* check the boolean condition */
   else if ((A == B )||( B < c) ) 
/* if condition is true then 
      execute the following statement*/ 
 {
      C = B* A;
   }else
      c++;
}

Arduino - If …else statement

An if statement can be followed by an optional else statement, which executes when the expression is false.

if … else Statement Syntax

if (expression) {
   Block of statements;
}
else {
   Block of statements;
}

if…else Statement – Execution Sequence

If Else Statement

Example

/* Global variable definition */
int A = 5 ;
int B = 9 ;

Void setup () {

}

Void loop () {
   /* check the boolean condition */
   if (A > B) 
 /* if condition is true then execute the following statement*/  
{
      A++;
   }else {
      B -= A;
   }
}

Arduino - Control Statements

Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program. It should be along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.
Following is the general form of a typical decision making structure found in most of the programming languages −
Decision Making

 
Powered by Blogger