• Home
  • Prakash
    • R and D
    • Smart Home
  • Basics
    • Capacitors
      • Color codeing Disc Capacitor Capacitor characterstics Polarity Non Polarity Series Connection Parallel Connection
    • Diodes
      • Zener Diode Light Emitting Diode Signal Diode Photo Diode
    • Inductors
    • Transistor
      • Silicon Germenium NPN PNP MOSFET SCR
    • Resistors
      • Color codeing 4-Band 5-Band Series Parallel Potential Meter
    • Logics
      • Analog Logic
      • Digital Logic
      • Hexa Decimal Numbers
      • Octal Numbers
      • Binary Fraction
      • Binay to Decimal
    • OP-Amplifiers
      • Basics
      • Oscillators
      • Transistor Switch
      • 555 IC circuits
      • Waveform Generators
      • 741 IC Circuits
    • Power supply
      • Transformer
      • Halfwave Rectifier
      • Fullwave Rectifier
      • Bridge Rectifier
      • 78xx Series
      • 0 to 30v Regulator
  • Modules
    • H-Bridge
      • L293D Bridge
      • Relay Bridge
    • RF 434MHz Modules
    • Relay Modules
    • Push to ON switch
    • Push to OFF switch
  • Sensors
    • Analog sensors List-1
      • LDR Photo Diode Solar Cell Transducers Temperature Humidity Sensor Soil Moisture Ranger Sensor Range Detection
    • Analog sensors List-2
      • Flame Sensor Force Sensor Flex Sensor Ambient Sensor Motion Sensor Vibration Sensor Sound Sensor UltraSonic Sensor GrayScale Sensor
    • Digital Sensors
      • Touch Sensor Tilt Sensor Signal
    • 3-Axis Sensor
    • Gyro Sensor
  • Projects
    • Embedded
      • Mini Projects 8051 Arduino NodeMCU MSP430 Raspberry IOT ARM
    • C #
      • Visual Basic Visual Studio
    • Matlab
    • VLSI
    • PHP-HTML
    • Contribute
  • Downloads
  • Technology

Arduino 7 Segment LED Display and Counter


This is a simple 0 to 9 counter circuit constructed using Arduino! Here, a common cathode 7-segment LED display is connected to Arduino for displaying the digits.
The code (Arduino sketch) allows push button increment of the counter from 0 to 9.
The whole circuit can be powered from a standard 9V PP3/6F22 battery, or from any suitable Arduino power adaptor



                                     7 segment led display


The seven segment display is infact a very simple device. It is a combination of 8 LEDs (the decimal point -DP- is the 8th), which can be arranged so that different combinations can be used to make numerical digits.

Details of a common cathode type 7 segment LED display is shown here. Note that pins 3 and 8 of the display is the cathode terminals.

                                             arduino 7 segment display



Just follow the schematic circuit diagram to make the entire project.
Arduino pins 2, 3, 4, 5, 6, 7 and 8 should go to Display pins 7, 6, 4, 2, 1, 9 and 10 in correct order. In case of any doubt refer this table. Push Switch (S1) input point is at pin 9 of the Arduino.
                                         arduino to display pins

Connecting the display pins directly to Arduino I/O pins is not a good practice. For testing purpose only one 330 Ohm resistor (R2) is added between ground rail (0V) and the common cathode pins (3 & 8). It is better to directly connect pins 3 & 8 of the display to ground rail. Next add a 330 Ohm resistor between each of the other connections to the Arduino.
CODE
  1. /*
  2. Arduino 7-Segment LED Display for Common Cathode Displays
  3. Arduino Pins: 2,3,4,5,6,7,8
  4. Display Pins: 7,6,4,2,1,9,10
  5. Display Pins 3&8 should go to GND
  6. Switch Input is at Pin 9
  7. */
  8. byte numbers[10] = {
  9. B11111100, B01100000, B11011010, B11110010, B01100110,
  10. B10110110, B10111110, B11100000, B11111110, B11100110
  11. };
  12. void setup() {
  13. for(int i = 2; i <= 8; i++) {
  14. pinMode(i, OUTPUT);
  15. }
  16. pinMode(9, INPUT);
  17. }
  18.  
  19. int counter = 0;
  20. bool go_by_switch = true;
  21. int last_input_value = LOW;
  22.  
  23. void loop() {
  24. if(go_by_switch) {
  25. int switch_input_value = digitalRead(9);
  26. if(last_input_value == LOW && switch_input_value == HIGH) {
  27. counter = (counter + 1) % 10;
  28. }
  29. last_input_value = switch_input_value;
  30. } else {
  31. delay(500);
  32. counter = (counter + 1) % 10;
  33. }
  34. writeNumber(counter);
  35. }
  36.  
  37. void writeNumber(int number) {
  38. if(number < 0 || number > 9) {
  39. return;
  40. }
  41. byte mask = numbers[number];
  42. byte currentPinMask = B10000000;
  43. for(int i = 2; i <= 8; i++) { if(mask & currentPinMask) digitalWrite(i,HIGH); else digitalWrite(i,LOW); currentPinMask = currentPinMask >> 1;
  44. }
  45. }


  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Related Posts:

  • Resistor 5-Band Color Code 5-band Resistor Colour Code                                   … Read More
  • Resistor 4-Band Colur code 4-band Resistor Colour Code   The coloured bands are shown as:  YELLOW , VIOLET, ORANGE and GOLD. Then … Read More
  • Potential Meter Potentiometers Resistors provide a fixed value of resistance that blocks or resists the flow of electrical current around a circuit, as we… Read More
  • IR Detector Circuit using 555 Timer IC   Infrared sensors are much common in our electronics life. They are used in many real time applications like for opening and closing t… Read More
  • GAS LEAK DETECTOR                      Here is a gas leak detector circuit that detects the leakage of LPG… Read More
Terms and Conditions -
Privacy Policy -

Contact Us

Name

Email *

Message *