SEARCH
TOOLBOX
LANGUAGES
modified on 17 September 2014 at 19:53 ••• 7,211 views

06-02 TwoDigitCounter

From Manuals

(Difference between revisions)
Jump to: navigation, search
(Created page with 'This program counts 0 to 99 and displays them on a two digit common cathode 7-segment display. /* Program Example 6.2: Display counter for 0-99 …')
 
Line 1: Line 1:
This program counts 0 to 99 and displays them on a two digit common cathode 7-segment display.
This program counts 0 to 99 and displays them on a two digit common cathode 7-segment display.
 +
The signals used for this example are listed below:
 +
{| border="1" cellpadding="5" cellspacing="2" align="center" style="text-align: center;"
 +
|+ align="bottom"|'''Signals Used and Connector Locations for Example 06-02'''
 +
|'''Signal'''
 +
|'''LPC4330 PIN NAME'''
 +
|'''BAM210E'''
 +
|'''BAM210'''
 +
|'''BAM200E'''
 +
|'''BAM200'''
 +
|'''Used for'''
 +
|-
 +
|D0
 +
|P6_5
 +
|J9-1
 +
|J9-1
 +
|S2-5
 +
|S2-5
 +
|Ones Segment A
 +
|-
 +
|D1
 +
|P6_4
 +
|J9-2
 +
|J9-2
 +
|S2-4
 +
|S2-4
 +
|Ones Segment B
 +
|-
 +
|D2
 +
|P1_7
 +
|J9-3
 +
|J9-3
 +
|S3-7
 +
|S3-7
 +
|Ones Segment C
 +
|-
 +
|D3
 +
|P4_0
 +
|J9-3
 +
|J9-3
 +
|S3-7
 +
|S3-7
 +
|Ones Segment D
 +
|-
 +
|D4
 +
|P6_9
 +
|J9-4
 +
|J9-4
 +
|S8-7
 +
|n/p
 +
|Ones Segment E
 +
|-
 +
|D5
 +
|P5_5
 +
|J9-5
 +
|J9-5
 +
|S3-8
 +
|S3-8
 +
|Ones Segment F
 +
|-
 +
|D6
 +
|P5_7
 +
|J9-6
 +
|J9-6
 +
|S3-9
 +
|S3-9
 +
|Ones Segment G
 +
|-
 +
|D7
 +
|P7_6
 +
|J9-7
 +
|J9-7
 +
|S4-6
 +
|S4-6
 +
|Ones Segment DP
 +
|-
 +
|D8
 +
|P6_12
 +
|J10-1
 +
|J10-1
 +
|S10-3
 +
|n/p
 +
|Tens Segment A
 +
|-
 +
|D9
 +
|P5_0
 +
|J10-2
 +
|J10-2
 +
|S1-4
 +
|S1-4
 +
|Tens Segment B
 +
|-
 +
|D10
 +
|P4_6
 +
|J10-3
 +
|J10-3
 +
|S2-3
 +
|S2-6
 +
|Tens Segment C
 +
|-
 +
|D11
 +
|P4_8
 +
|J10-4
 +
|J10-4
 +
|S2-7
 +
|S2-7
 +
|Tens Segment D
 +
|-
 +
|D12
 +
|P4_9
 +
|J10-5
 +
|J10-5
 +
|S2-8
 +
|S2-8
 +
|Tens Segment E
 +
|-
 +
|D13
 +
|P4_10
 +
|J10-6
 +
|J10-6
 +
|S2-9
 +
|S2-9
 +
|Tens Segment F
 +
|-
 +
|D16
 +
|P2_3
 +
|J10-9
 +
|J10-9
 +
|S4-8
 +
|S4-8
 +
|Tens Segment G
 +
|-
 +
|D17
 +
|P2_4
 +
|J10-10
 +
|J10-10
 +
|S4-9
 +
|S4-9
 +
|Tens Segment DP
 +
|-
 +
|}
 +
 +
The following schematic can be used to build the circuit with a BAM210E or BAM210.
 +
[[Image:BAM210_06_02_SCH.png|center|alt=BAM210|frame|<div align="center">'''Schematic for example 06-02''']]
 +
 +
<div style="text-align: left;">
  /* Program Example 6.2: Display counter for 0-99
  /* Program Example 6.2: Display counter for 0-99
                                                               */
                                                               */
Line 37: Line 182:
  }
  }
-
 
+
The following image shows the built circuit on a BAM210E.
[[Image:BAM210_TwoDigitCounter.jpeg|center|]]
[[Image:BAM210_TwoDigitCounter.jpeg|center|]]
-
 
-
 
-
[[Image:BAM210_06_02_SCH.png|center|alt=BAM210|frame|<div align="center">'''Schematic for example 06-02''']]
 

Current revision as of 19:53, 17 September 2014

This program counts 0 to 99 and displays them on a two digit common cathode 7-segment display.

The signals used for this example are listed below:

Signals Used and Connector Locations for Example 06-02
Signal LPC4330 PIN NAME BAM210E BAM210 BAM200E BAM200 Used for
D0 P6_5 J9-1 J9-1 S2-5 S2-5 Ones Segment A
D1 P6_4 J9-2 J9-2 S2-4 S2-4 Ones Segment B
D2 P1_7 J9-3 J9-3 S3-7 S3-7 Ones Segment C
D3 P4_0 J9-3 J9-3 S3-7 S3-7 Ones Segment D
D4 P6_9 J9-4 J9-4 S8-7 n/p Ones Segment E
D5 P5_5 J9-5 J9-5 S3-8 S3-8 Ones Segment F
D6 P5_7 J9-6 J9-6 S3-9 S3-9 Ones Segment G
D7 P7_6 J9-7 J9-7 S4-6 S4-6 Ones Segment DP
D8 P6_12 J10-1 J10-1 S10-3 n/p Tens Segment A
D9 P5_0 J10-2 J10-2 S1-4 S1-4 Tens Segment B
D10 P4_6 J10-3 J10-3 S2-3 S2-6 Tens Segment C
D11 P4_8 J10-4 J10-4 S2-7 S2-7 Tens Segment D
D12 P4_9 J10-5 J10-5 S2-8 S2-8 Tens Segment E
D13 P4_10 J10-6 J10-6 S2-9 S2-9 Tens Segment F
D16 P2_3 J10-9 J10-9 S4-8 S4-8 Tens Segment G
D17 P2_4 J10-10 J10-10 S4-9 S4-9 Tens Segment DP

The following schematic can be used to build the circuit with a BAM210E or BAM210.

File:BAM210 06 02 SCH.png
Schematic for example 06-02
/* Program Example 6.2: Display counter for 0-99
                                                              */
#include "mbed.h"
BusOut Seg1(D0,D1,D2,D3,D4,D5,D6,D7); // A,B,C,D,E,F,G,DP
BusOut Seg2(D8,D9,D10,D11,D12,D13,D16,D17);

char SegConvert(char SegValue);     // function prototype
int main() {                        // main program
  while (1) {                       // infinite loop
    for (char j=0;j<10;j++) {       // counter loop 1
      Seg2=SegConvert(j);           // tens column
      for (char i=0;i<10;i++) {     // counter loop 2
          Seg1=SegConvert(i);       // units column
          wait(0.2);
      }
    }
  }
}

char SegConvert(char SegValue) {        // function 'SegConvert'
  char SegByte=0x00;
  switch (SegValue) {                   //DP G F E D C B A
    case 0 : SegByte = 0x3F;break;      // 0 0 1 1 1 1 1 1 binary
    case 1 : SegByte = 0x06;break;      // 0 0 0 0 0 1 1 0 binary
    case 2 : SegByte = 0x5B;break;      // 0 1 0 1 1 0 1 1 binary
    case 3 : SegByte = 0x4F;break;      // 0 1 0 0 1 1 1 1 binary
    case 4 : SegByte = 0x66;break;      // 0 1 1 0 0 1 1 0 binary
    case 5 : SegByte = 0x6D;break;      // 0 1 1 0 1 1 0 1 binary
    case 6 : SegByte = 0x7D;break;      // 0 1 1 1 1 1 0 1 binary
    case 7 : SegByte = 0x07;break;      // 0 0 0 0 0 1 1 1 binary
    case 8 : SegByte = 0x7F;break;      // 0 1 1 1 1 1 1 1 binary
    case 9 : SegByte = 0x6F;break;      // 0 1 1 0 1 1 1 1 binary
  }
    return SegByte;
}

The following image shows the built circuit on a BAM210E.