Skip to main content

Posts

Privacy Policy

Introduce We always strive to protect our customers' personal information. Customer Data The application fully commits not to collect and share data with third parties.

Using PIC16F887 microcontroller to control 8 single leds on and off using timer interrupt T1

Requirements: Use a PIC16F887 microcontroller to control 8 single leds on and off using the timer interrupt T1 with a delay period of 262ms.  Circuit diagram on Proteus simulation software  Figure 1. Controlling 8 LEDs to turn on and off using interrupts Main program : File: main.c ___________________ #INCLUDE <16F887.H> #FUSES NOWDT,PUT,HS,NOPROTECT,NOLVP #USE DELAY(CLOCK=20M) UNSIGNED INT8 X; #int_timer1 void interrupt_timer1() {    X=~X;    OUTPUT_D(X); } VOID MAIN() {     SET_TRIS_D(0x00); X=0X00; OUTPUT_D(X);    SETUP_TIMER_1(T1_INTERNAL | T1_DIV_BY_8);    SET_TIMER1(0);    ENABLE_INTERRUPTS(GLOBAL); ENABLE_INTERRUPTS(INT_TIMER1);    WHILE(TRUE) {} } ___________________ Link download:  https://drive.google.com/file/d/1e_8QOGfguNwGeuFN-T0MR9-vJyvMLAmz/view

Use PWM of PIC 16F887 to control 1 led

Requirements: Use PWM of PIC 16F887 to control 1 led. Let the frequency of the quartz capacitor be 20MHz. Given a PWM period of 0.8ms. Let's calculate the parameters and write a program to control the led light with level 1 equal to 1 tenth of the maximum brightness.   Circuit diagram on Proteus simulation software: Figure 1. The control circuit changes the light intensity of the lamp using PWM Main program : File: main.c ___________________ #INCLUDE <16F887.H> #FUSES NOWDT,PUT,HS,NOPROTECT,NOLVP #USE DELAY(CLOCK=20M) UNSIGNED INT16 BIEN_TOC_DO; VOID MAIN() {    SET_TRIS_C(0X00);    SETUP_CCP1(CCP_PWM);    SETUP_TIMER_2(T2_DIV_BY_16,249,1);    BIEN_TOC_DO=500;    SET_PWM1_DUTY(BIEN_TOC_DO);    WHILE(TRUE){} } ___________________ Link download:  https://drive.google.com/file/d/1bTFkDOBbnVMOfTfktRKmekfiYAq1Ipf6/view

Use the ADC of the PIC 16F887 microcontroller and the LM35 sensor to measure the temperature and display it on 3 led 7 segments common anode

Requirements: Use the ADC of the PIC16F887 microcontroller and the LM35 sensor to measure the temperature displayed on 3 led 7 segments common anode using 3 ports, only displaying units, tens and hundreds. Use a reference voltage source VREF+ connected to VDD with 5V and VREF- connected to a VSS source of 0V  Circuit diagram on Proteus simulation software Figure 1. Circuit diagram for measuring temperature using PIC16F887 displayed on 3 leds directly Main program : File: main.c ___________________ #INCLUDE<TV_16F887.C> UNSIGNED INT16 KQADC; UNSIGNED INT J,MATRAM; VOID HIEN_THI() {    MATRAM = MA7DOAN[KQADC/100];    IF (MATRAM == 0XC0) MATRAM=0XFF;    OUTPUT_B(MA7DOAN[KQADC%10]);    OUTPUT_D(MA7DOAN[KQADC/10%10]);    OUTPUT_C(MATRAM); } VOID MAIN() {    SET_TRIS_B(0x00); SET_TRIS_D(0x00);    SET_TRIS_C(0x00); SET_TRIS_A(0xFF);    SETUP_ADC(ADC_CLOCK_DIV_2);    SETUP_ADC_PORTS(SAN0);    SET_ADC_CHANNEL(0);    WHILE(TRUE)    {       KQADC=0;       FOR (J=0; J<200; J++)       {  

Using 16F887 microcontroller to count external pulses using T0, the counting results are displayed on 3 leds directly connected to 3 ports

Requirements: Using microcontroller 16F887 to count external pulses using T0, counting results displayed on 3 leds directly connected to 3 ports, counting limit from 000 to 255, when equal to 255, return to 0  Circuit diagram on Proteus simulation software: Figure 1. Counting external pulses using counter T0 Main program : Use PIC16F887 to count external pulses using T0.c ________________ #INCLUDE<TV_16F887.C> UNSIGNED INT8 T0, MATRAM, MACHUC; VOID MAIN() {    SET_TRIS_B(0x00); SET_TRIS_C(0x00); SET_TRIS_D(0x00);    SETUP_TIMER_0(T0_EXT_L_TO_H | T0_DIV_1);    SET_TIMER0(0);    WHILE(TRUE)    {       T0=GET_TIMER0();       MATRAM=MA7DOAN[T0/100]; MACHUC=MA7DOAN[T0/10%10];       IF (MATRAM==0XC0)       {          MATRAM=0XFF;          IF (MACHUC==0XC0) MACHUC=0XFF;       }       OUTPUT_B(MA7DOAN[T0%10]);       OUTPUT_D(MACHUC);       OUTPUT_C(MATRAM);    } } ________________ TV_16F887.c Library: TV_16F887.c ________________ #INCLUDE <16F887.H> #FUSES NOWDT,PUT,HS,NOPROTECT,NO

Using microcontroller PIC 16F887 to control 8 single leds on and off using timer T1 with period delay is 2s, 1 second on, 1 second off

Circuit diagram Interface PIC16F887 microcontroller with LED on Proteus software:  Figure 1. PIC16F887 microcontroller interface with LED Main program : Control 8 single leds on and off using timer T1.c __________________ #INCLUDE <16F887.H> #FUSES NOWDT,PUT,HS,NOPROTECT,NOLVP #USE DELAY(CLOCK=20M) #BIT TMR1IF = 0x0C.0 UNSIGNED INT8 X, BDT; VOID MAIN() {    SET_TRIS_D(0x00); X=0; BDT=0; OUTPUT_D(X);    SETUP_TIMER_1(T1_INTERNAL | T1_DIV_BY_8);    SET_TIMER1(3036);    WHILE(TRUE)    {       IF (TMR1IF==1)       {          TMR1IF=0; SET_TIMER1(3036); BDT++;          IF (BDT ==10)          {             OUTPUT_D(X); X=~X; BDT = 0;          }       }    } } __________________ Link download:  https://drive.google.com/file/d/1PUnAsc0963tt-ZWX7K2UIK_FQ0DcIKay/view