Pages

Thursday 26 April 2018

ARM-1768-LPCDisplay the Hex digits 0 to F on a 7-segment LED with an appropriate delay in between

Program:
/** Connections
  * A(development board) -> P2.0
* B(development board) -> P2.1
* C(development board) -> P2.2
* D(development board) -> P2.3
* E(development board) -> P2.4
* F(development board) -> P2.5
* G (development board) -> P2.6
* DIG1/DIG2/DIG3/DIG4(devp board) -> P2.7
  */

#include <lpc17xx.h> 
#include "7segment.h"
#include "delay.h"

/* Initialize the character to be displayed on the 7 segment display */
uint8_t ch[] = {'0', '1', '2', '3', '4', '5', '6', '7',
              '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

uint8_t i = 0;

/* start the main program */   
int main()

uint8_t data;

/* Initialize the 7 Segment display */
//A,B,C,D,E,F,G,DIG
  SEG_INIT(2,3,4,5,6,7,8,9);

  while(1)
  {
    for(i = 0; i < 16; i++)
{
switch(ch[i])
{
case '0' : data = 0x40; break;
case '1' : data = 0x79; break;
case '2' : data = 0x24; break;
case '3' : data = 0x30; break;
case '4' : data = 0x19; break;
case '5' : data = 0x12; break;
case '6' : data = 0x02; break;
case '7' : data = 0x78; break;
case '8' : data = 0x00; break;
case '9' : data = 0x18; break;
case 'A' : data = 0x08; break;
case 'B' : data = 0x00; break;
case 'C' : data = 0x46; break;
case 'D' : data = 0x40; break;
case 'E' : data = 0x06; break;
case 'F' : data = 0x0E; break;
default  : data = 0x40; break;
}

/* Display the character on seven segment LED */
Display(data);
DELAY_ms(50);
}
  }
}

Hardware Connection
Connect R5 (development board) to P2.0 (segment ‘a’)
Connect R6 (development board) to P2.1 (segment ‘b’)
Connect R7 (development board) to P2.2 (segment ‘c’)
Connect R8 (development board) to P2.3 (segment ‘d’)
Connect R9 (development board) to P2.4 (segment ‘e’)
Connect R10 (development board) to P2.5 (segment ‘f’)
Connect R11 (development board) to P2.6 (segment ‘g’)
Connect DIG /DIG2/DIG3/DIG4 (development board) to P2.7


Output
The 7Segment Display starts displaying the characters from 0 – F.

 FOR DETAIL INFORMATION ABOUT ARM CORTEX DEVELOPMENT KIT : CLICK HERE

No comments:

Post a Comment