A basic intro to MikroC for PIC UART library and its usage by sending and receiving characters.

Поділитися
Вставка
  • Опубліковано 18 жов 2024
  • Hello guys Welcome to learning microcontrollers,
    Guys I had made a course for you guys on Udemy.
    This course will teach you how to directly get your hands dirty on arduino and make useful projects to earn money.
    Please do take this course on udemy this will greatly help me to grow my channel.
    You will assisting my channel by paying for that course.
    Here is the link to the course:
    www.udemy.com/...
    A quote:
    Learn from cradle to grave.
    /
    /
    /
    ////////////////////// Hello Guys,
    Welcome to learning Microcontrollers.
    I had made a course for you guys to learn under my direction supervision on Udemy.
    This course will make you a master of PIC microcontroller based projects making using MikroC for PIC software.
    Please do take this course the link is below. This will greatly help my channel aswell to grow.
    www.udemy.com/...
    A beautfiul quote:
    The road to sucess is always under construction.
    /
    /
    ///////////////////////////////////////////////////// Hello guys,
    Sending and receiving characters over UART in any microcontroller is very crucial in various projects. These chars act as signals to perform various tasks like turning motors or lights on and off.
    In this tutorial I am gonna use PIC16F877A with 2 LEDs and virtual terminal on proteus to show you how you can send and receive characters to PIC to perform various tasks.
    MikroC for PIC code from current video:
    char rec;
    void main() {
    // Initialize hardware UART1 and establish communication at 9600 bps
    UART1_Init(9600);
    Delay_ms(100);
    TRISB.F0 = 0;
    TRISB.F1 = 0;
    PORTB.F0 = 0;
    PORTB.F1 = 0;
    Delay_ms(100);
    while(1)
    {
    // If data is ready, read it:
    if (UART1_Data_Ready() == 1) {
    rec = UART1_Read();
    if (UART1_Tx_Idle() == 1) {
    UART1_Write(rec);
    }
    }
    if ( rec == 'a' )
    {
    PORTB.F0 = 1;
    PORTB.F1 = 0;
    }
    else if (rec == 'b' )
    {
    PORTB.F0 = 0;
    PORTB.F1 = 1;
    }
    else if (rec == 'c' )
    {
    PORTB.F0 = 1;
    PORTB.F1 = 1;
    }
    else
    {
    PORTB.F0 = 0;
    PORTB.F1 = 0;
    }
    }
    }
  • Наука та технологія

КОМЕНТАРІ • 3