The circuit connection of LEDs in common cathode and common anode is shown in above  figure. Here one can observe that, in CC the negative terminals of every LED is connected together  and brought out as GND. In CA the positive of every LED is connected together and brought out as  VCC. These CC and CA come in very handy while multiplexing several cells together.  Components Required  Hardware: ARDUINO UNO , power supply (5v), HDSP5503 seven segment display (two pieces) (any  common cathode will do ), 47uF capacitor (connected across power supply).  Software: arduino IDE (Arduino nightly)  Circuit Diagram and Working Explanation    The connections which are done for 7 segment display are given below:  PIN1 or E to PIN 6 of ARDUINO UNO  PIN2 or D to PIN 5  PIN4 or C to PIN 4  PIN5 or H or DP to PIN 9 ///not needed as we are not using decimal point  PIN6 or B to PIN 3  PIN7 or A to PIN 2
PIN9 or F to PIN 7  PIN10 or G to PIN 8  PIN3 or PIN8 or CC to ground through 100Ω resistor.  Now to understand the working, consider a seven segment display is connected to a port, so say  we have connected “A segment of display to PIN0”, “B segment of display to PIN1”, “A segment of  display to PIN3”, “A segment of display to PIN4”, “A segment of display to PIN5”, “A segment of  display to PIN6”. And is common ground type as shown in figure.    Here the common ground has to be connected to ground for the display to work. One can check  each segment of display by using multimeter in diode mode. Each segment should not be power  with a voltage greater than 4v, if did the display will be damaged permanently. For avoiding this a  common resistor can be provider at common terminal, as shown in circuit diagram.  Now, if we want to display a “0” in this display as shown in below figure.    We need to turn the LEDs of segments “A, B, C, D, E F”, so we need to power PIN0, PIN1, PIN2,  PIN3, PIN4 and PIN5. So every time we need a “0”, we need to power all the pins mentioned.  Now, if we want “1” on display
We need to power segments “B, C”, for segment B, C to turn ON we need to power PIN1, PIN2.  With both the pins high we get “1” on display. So as seen above we are going to power pins  corresponding to the digit that to be shown on display.  Here we are going to write a program turning each segment ON and OFF for a count 0-9. The  working of 0-9 counter is best explained step by step in C code given below:  Code  #define segA 2//connecting segment A to PIN2    #define segB 3// connecting segment B to PIN3    #define segC 4// connecting segment C to PIN4    #define segD 5// connecting segment D to PIN5    #define segE 6// connecting segment E to PIN6    #define segF 7// connecting segment F to PIN7    #define segG 8// connecting segment G to PIN8              int COUNT=0;//count integer for 0-9 increment    void setup()    {                for (int i=2;i<9;i++)                {                            pinMode(i, OUTPUT);// taking all pins from 2-8 as output                }
}    void loop()  {  switch (COUNT)              {              case 0://when count value is zero show”0” on disp            digitalWrite(segA, HIGH);            digitalWrite(segB, HIGH);            digitalWrite(segC, HIGH);            digitalWrite(segD, HIGH);            digitalWrite(segE, HIGH);            digitalWrite(segF, HIGH);            digitalWrite(segG, LOW);            break;              case 1:// when count value is 1 show”1” on disp            digitalWrite(segA, LOW);            digitalWrite(segB, HIGH);            digitalWrite(segC, HIGH);            digitalWrite(segD, LOW);            digitalWrite(segE, LOW);            digitalWrite(segF, LOW);
digitalWrite(segG, LOW);  break;    case 2:// when count value is 2 show”2” on disp  digitalWrite(segA, HIGH);  digitalWrite(segB, HIGH);  digitalWrite(segC, LOW);  digitalWrite(segD, HIGH);  digitalWrite(segE, HIGH);  digitalWrite(segF, LOW);  digitalWrite(segG, HIGH);  break;    case 3:// when count value is 3 show”3” on disp  digitalWrite(segA, HIGH);  digitalWrite(segB, HIGH);  digitalWrite(segC, HIGH);  digitalWrite(segD, HIGH);  digitalWrite(segE, LOW);  digitalWrite(segF, LOW);  digitalWrite(segG, HIGH);  break;    case 4:// when count value is 4 show”4” on disp  digitalWrite(segA, LOW);
digitalWrite(segB, HIGH);  digitalWrite(segC, HIGH);  digitalWrite(segD, LOW);  digitalWrite(segE, LOW);  digitalWrite(segF, HIGH);  digitalWrite(segG, HIGH);  break;    case 5:// when count value is 5 show”5” on disp  digitalWrite(segA, HIGH);  digitalWrite(segB, LOW);  digitalWrite(segC, HIGH);  digitalWrite(segD, HIGH);  digitalWrite(segE, LOW);  digitalWrite(segF, HIGH);  digitalWrite(segG, HIGH);  break;    case 6:// when count value is 6 show”6” on disp  digitalWrite(segA, HIGH);  digitalWrite(segB, LOW);  digitalWrite(segC, HIGH);  digitalWrite(segD, HIGH);  digitalWrite(segE, HIGH);
digitalWrite(segF, HIGH);  digitalWrite(segG, HIGH);  break;    case 7:// when count value is 7 show”7” on disp  digitalWrite(segA, HIGH);  digitalWrite(segB, HIGH);  digitalWrite(segC, HIGH);  digitalWrite(segD, LOW);  digitalWrite(segE, LOW);  digitalWrite(segF, LOW);  digitalWrite(segG, LOW);  break;    case 8:// when count value is 8 show”8” on disp  digitalWrite(segA, HIGH);  digitalWrite(segB, HIGH);  digitalWrite(segC, HIGH);  digitalWrite(segD, HIGH);  digitalWrite(segE, HIGH);  digitalWrite(segF, HIGH);  digitalWrite(segG, HIGH);  break;    case 9:// when count value is 9 show”9” on disp
digitalWrite(segA, HIGH);            digitalWrite(segB, HIGH);            digitalWrite(segC, HIGH);            digitalWrite(segD, HIGH);            digitalWrite(segE, LOW);            digitalWrite(segF, HIGH);            digitalWrite(segG, HIGH);            break;              break;            }            if (COUNT<10)            {                         COUNT++;                       delay(1000);///increment count integer for every second            }            if (COUNT==10)            {                       COUNT=0;// if count integer value is equal to 10, reset it to zero.                       delay(1000);            }  }
7 Interfacing of Relay and temperature sensor(LM 35) with Arduino.           LM35         LM35 is a temperature sensor which can measure temperature in the range of -55°C to 150°C.         It is a 3-terminal device that provides analog voltage proportional to the temperature. Higher the         temperature, higher is the output voltage.         The output analog voltage can be converted to digital form using ADC so that a microcontroller         can process it.         For more information about LM35 and how to use it, refer the topic LM35 Temperature Sensor in         the sensors and modules section.         Interfacing Diagram           Interfacing LM35 With Arduino UNO         Example         Measuring the temperature of surroundings using LM35 and displaying it on the serial monitor of         Arduino.         Here, LM35 output is given to analog pin A1 of Arduino UNO. This analog voltage is converted to         its digital form and processed to get the temperature reading.         Sketch for Temperature Measurement
const int lm35_pin = A1;            /* LM35 O/P pin */    void setup() {   Serial.begin(9600);  }    void loop() {       int temp_adc_val;       float temp_val;       temp_adc_val = analogRead(lm35_pin);  /* Read Temperature */       temp_val = (temp_adc_val * 4.88); /* Convert adc value to equivalent voltage */       temp_val = (temp_val/10); /* LM35 gives output of 10mv/°C */       Serial.print(\"Temperature = \");       Serial.print(temp_val);       Serial.print(\" Degree Celsius\\n\");       delay(1000);    }    8 Interface an ultrasonic sensor with Arduino to calculate the distance and print on LCD.        1. Interface the DC motor with Arduino using motor driven IC.        2. Interface the Bluetooth with Arduino and control the LED.    Interface Ultrasonic sensor with Arduino Uno  Ultrasonic sensor is one of the main part of numerous projects. Here we are going to interface a  Ultrasonic sensor HC-SR 05 with Arduino Uno.  In this project we discuss,         Connect a Ultrasonic Sensor HC-SR 05 to Arduino.       Read the sensor and convert it to length.       Print the length to the Serial Monitor.  HC - SR 05  Before starting we need to know about the working of Ultrasonic Sensor HC-SR 05. Actually it  consist of an ultrasonic transmitter and an ultrasonic reciver. First ultrasonic transmitter send an  ultrasonic wave. This signal will collide with the object and reflect the signal. The receiver will  receive the reflected signal. The distance calculated by the time taken to receive the reflected. and  the speed of sound in air. The speed of sound in air at room temperature is 340 Meter/Second or  0.034 centimeter/microsecond. The equation for calculating time is,  Time=Distance/speed of sound  If the object is 10 CM away from the sensor, You will get the time as per the equation is,  10/0.034 = 294.11 Microseconds  But you will get the value from the Echo pin is 588.22. This is because of the sound wave needs to  travel forward and bounce backward. So we need to devide that value by 2 for get the actual  value(time). Here we want to calculate the distance from the time. So re-arrange the equation we  will get,  Distance=Time x speed of sound  The time to start.  Buy electronic components with free shipping on utsource.net  Step - 1
Open the Arduino IDE (refer my previous article for introduction to Arduino IDE here) and we need  define two pins, echoPin on digital pin 2 and trigPin on digital pin 3. by using the keyword \"define'.  Next declare two variables, one is \"duration\". This is for store the duration of sound wave  traveled. Other is \"distance\" for store the distance calculated.  #define echoPin 2  #define trigPin 3  long duration;  int distance;  definition part is completed. Next setup part.  Step - 2  In the void setup() function we need to begin the serial communication with baurd rate as 9600. It  is done by the keyword \"Serial.begin(9600)\". Then set the trigPin as \"OUTPUT\", by the keyword  \"pinMode(trigPin, OUTPUT)\". Because the trigPin is the input pin of transmitter of sensor module.  Now we need to set the echoPin as \"INPUT\". By the keyword \"pinMode(echoPin, INPUT)\".  void setup(){   Serial.begin(9600);   pinMode(trigPin,OUTPUT);   pinMode(echoPin,INPUT);  }  setup part is completed.  Now we need to code the loop part.  Step - 3  Now the trigPin state is in a float condition. We need to set it as \"LOW\". for this purpose we use  the keyword \"digitalWrite(trigPin, LOW)\". Then hold this state for 2 microseconds by the keyword  \"delayMicroseconds(2)\".  digitalWrite(trigPin,LOW);  delayMicroseconds(2);  Now we need to set the trigPin \"HIGH\" for 10 seconds, with the same keyword mentioned above.  Only change the parameter.  digitalWrite(trigpin,HIGH);  delayMicroseconds(10);  Then set the trigPin as \"LOW\" state.  digitalWrite(trigpin,LOW);  Now read the echoPin and put it to the function \"pulseIn(echoPin, HIGH)\". This returns the total  travel time. So we need to store this return value to the variable \"duration\".  duration=pulseIn(echoPin,HIGH);  The total travel time is now stored in the variable \"duration\"  Now we can calculate the distance from this duration by using the equation. And store calculated  value(distance) to the variable \"distance\". The eqution is explained above  distance=(duration*0.034/2);  The distance from the sensor to the object is now stored in the variable \"distance\".  Then we need to display it to screen. For this purpose, here we using the serial communication.  Ypu can also use LCD, Sven Segment Display, OLED Disply, etc...(The will change). First print a  headingor a message. Here I am going to print \"Distance\". by using \"Serial.print(\"Distance : \" )\".  After that print the distance to the serial monitor, we use the keyword \"Serial.println(distance)\".  Then print the unit by \"Serial.println(\" cm \")\". Here I used a \"ln\" with \"Serial.print()\". It's for start a  new line. The code is like,
Serial.print(\"Distance : \" );  Serial.print(distance)\";  Serial.println(\" cm \")\";  The code is completed. Upload the code to Arduino Uno. The complete code is given in the code  part.  Step - 4  Next add a 1 second delay  delay(1000);  Step - 5  Then connect the Ultrasonic sensor HC -SR05 to Arduino Uno with female to male jumber wire.  HC -SR05 Arduino Uno  Vcc 5V  echo D2  trig D3  GND GND  Step - 5  Now we need to open Serial monitor from top right corner of Arduino IDE. Please ensure the  selected COM port(in Windows OS) is right and braud rate is 9600.  Please dont copy-paste my code. Make your own one. That will help to create projects by using  Ultrasonic sensor  CODE  Interface Ultrasonic sensor with Arduino Uno Arduino  //sketch created by Akshay Joseph  //follow me on Instagram five_volt_player    #define echoPin 2  #define trigPin 3    long duration;  int distance;  void setup(){   Serial.begin(9600);   pinMode(trigPin,OUTPUT);   pinMode(echoPin,INPUT);  }  void loop(){   digitalWrite(trigPin,LOW);   delayMicroseconds(2);   digitalWrite(trigPin,HIGH);   delayMicroseconds(10);   digitalWrite(trigPin,LOW);    duration=pulseIn(echoPin,HIGH);   distance=(duration*0.034/2);   Serial.print(\"Distance : \");   Serial.print(distance);   Serial.println(\" cm \");   delay(1000);
}  SCHEMATICS  Interface Ultrasonic sensor with Arduino Uno
                                
                                
                                Search
                            
                             
                    