Demo entry 6361005

py

   

Submitted by anonymous on May 03, 2017 at 07:00
Language: C. Code size: 2.5 kB.

/* 

 * File:   LED1.c

 * Author: Participant

 *

 * Created on 28 April, 2017, 10:38 AM

 */

#include <stdio.h>
#include <stdlib.h>

#pragma config FOSC = HS
#pragma config WDTEN = OFF
#pragma config XINST = OFF

#include <p18f87j11.h>        // for PIC18F87j11 MCU
#include <xc.h>

#define _XTAL_FREQ 32000000// Fosc frequency for _delay() library

unsigned char NO1 = 0b00000110; // Display 1
unsigned char NO2 = 0b01101011; // Display 2
unsigned char NO3 = 0b01001111; // Display 3
unsigned char NO4 = 0b01010110; // Display 4
unsigned char NO5 = 0b01011101; // Display 5
unsigned char NO6 = 0b01111101; // Display 6
unsigned char NO7 = 0b00000111; // Display 7
unsigned char NO8 = 0b01111111; // Display 8
unsigned char NO9 = 0b01011111; // Display 9
unsigned char NO0 = 0b00111111; // Display 0
unsigned char Dot = 0b10000000; // Display .

void main(void) {
    LATD = 0x00; // Initialize Port D
    TRISD = 0x00; // Configure Port D as O/P

    while (1) {
        LATD = NO1; // Send no.1 to Port D
        for (int i = 0; i <= 100; i++) {
            __delay_ms(10);
        }//delay for 1s

        LATD = NO2; // Send no.2
        for (int i = 0; i <= 100; i++) {
            __delay_ms(10);
        }//delay for 1s

        LATD = NO3; // Send no.3
        for (int i = 0; i <= 100; i++) {
            __delay_ms(10);
        }//delay for 1s

        LATD = NO4; // Send no.4
        for (int i = 0; i <= 100; i++) {
            __delay_ms(10);
        }//delay for 1s

        LATD = NO5; // Send no.4
        for (int i = 0; i <= 100; i++) {
            __delay_ms(10);
        }//delay for 1s

        LATD = NO6; // Send no.6
        for (int i = 0; i <= 100; i++) {
            __delay_ms(10);
        }//delay for 1s

        LATD = NO7; // Send no.7
        for (int i = 0; i <= 100; i++) {
            __delay_ms(10);
        }//delay for 1s

        LATD = NO8; // Send no.8
        for (int i = 0; i <= 100; i++) {
            __delay_ms(10);
        }//delay for 1s

        LATD = NO9; // Send no.9
        for (int i = 0; i <= 100; i++) {
            __delay_ms(10);
        }//delay for 1s

        LATD = NO0; // Send no.0
        for (int i = 0; i <= 100; i++) {
            __delay_ms(10);
        }//delay for 1s

        LATD = Dot; // Send dot
        for (int i = 0; i <= 100; i++) {
            __delay_ms(10);
        }//delay for 1s
    }
} 

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).