Hello Readers, welcome to my Blog BloggerTipsTricks. com - A Blog For Bloggers By A Blogger. I'm Arun, an entrepreneur Blogger from India.

PC to ATmega16 Communication with LED Display

12210
Mark as Favourite

Several devices collect data from sensors and other input devices and these data needs to be sent to another devices, like a computer, for further processing. Data communication between two devices is generally done in two ways: parallel and serial. In the parallel communication, data transfer is fast and uses more number of signal lines. This mode is good for short range data transfer. Serial communication on the other hand, uses only one or two data lines to transfer data and is generally used for long distance communication.

There are many ways to interface microcontroller to computer; the easiest way is through serial port of computer. But the current generation PCs and Laptops do not have Serial Ports in them. So, we will use a USB to Serial Cable with computer. A USB to Serial Cable creates a virtual serial port in the computer. The communication between a PC and a microcontroller through serial port can be achieved by using USART protocol in asynchronous mode, MAX232 and a terminal software. USART is a full duplex communication protocol used to transfer data between two device serially, MAX232 is a level converter which converts the CMOS logic levels from microcontroller into RS232 logic levels of computer and vice versa. And the terminal software is used to send data from computer and to see received data in computer.

In this project, we will learn How to interface a PC with AVR ATmega16 microcontroller and How to send data from computer to microcontroller. Here, data from the computer will be sent to ATmega16 microcontroller through the RealTerm terminal software. We will press different keys from the computer keyboard and the RealTerm terminal software will send the ASCII value of the each pressed keys to the microcontroller through the serial port of computer. The microcontroller will receive each data sent by computer and it will display it in the 1×8 LED array. The above process continues forever.

Softwares Required

Hardwares Required

Name / Unit Price Quantity Total Price
AVR Trainer Board-100 with ATmega16
Rs. 700.00
1pc
Rs.700.00
AVR USB Programmer
Rs. 350.00
1pc
Rs.350.00
12V, 1A DC SMPS Adaptor
Rs. 130.00
1pc
Rs.130.00
RS-232 Driver Board
Rs. 200.00
1pc
Rs.200.00
USB to Serial Cable-Y-105
Rs. 350.00
1pc
Rs.350.00
10 to 10 FRC Female to Female Connector
Rs. 15.00
3pc
Rs.45.00
TOTAL Rs.1775.00

Circuit Diagram

C Program

Fullscreen
 

 //**************************************************************//
//System Clock                             :8MHz
//Software                                    :AVR Studio 4
//USART Baud Rate                     :9600
//USART Data Bits                       :8
//USART Stop Bits                       :1
//USART Mode                            :Asynchronous Mode
//USART Parity                            :No Parity
//**************************************************************//

#include<avr/io.h>
/*Includes io.h header file where all the Input/Output Registers and its Bits are defined for all AVR microcontrollers*/

#define          F_CPU          8000000
/*Defines a macro for the delay.h header file. F_CPU is the microcontroller frequency value for the delay.h header file. Default value of F_CPU in delay.h header file is 1000000(1MHz)*/

#include<util/delay.h>
/*Includes delay.h header file which defines two functions, _delay_ms (millisecond delay) and _delay_us (microsecond delay)*/

#include<avr/usart.h>
/*Includes usart.h header file which defines different functions for USART. USART header file version is 1.1*/

int main(void)
{

DDRB=0xff;
/*All the 8 pins of PortB are declared output (LED array is connected)*/

char usart_received_data;
/*Variable declaration*/

usart_init();
/*USART initialization*/

usart_string_transmit(“ABLab Solutions”);
/*Transmits string to PC*/

usart_data_transmit(0x0d);
/*Transmits Carriage return to PC for new line*/

usart_string_transmit(“www.ablab.in”);
/*Transmits string to PC*/

usart_data_transmit(0x0d);
/*Transmits Carriage return to PC for new line*/

usart_string_transmit(“Press any key from keyboard:”);
/*Transmits string to PC*/

usart_data_transmit(0x0d);
/*Transmits Carriage return to PC for new line*/

/*Start of infinite loop*/
while(1)
{

usart_received_data=usart_data_receive();
/*Microcontroller receives data from PC */

PORTB=usart_received_data;
/*Data received from PC is displayed in LED array*/

usart_data_transmit(0x0d);
/*Transmits Carriage return to PC for new line*/

}

}
/*End of Program*/

  

 //**************************************************************//
//System Clock                             :8MHz
//Software                                    :AVR Studio 4
//USART Baud Rate                     :9600
//USART Data Bits                       :8
//USART Stop Bits                       :1
//USART Mode                            :Asynchronous Mode
//USART Parity                            :No Parity
//**************************************************************//

#include<avr/io.h>
/*Includes io.h header file where all the Input/Output Registers and its Bits are defined for all AVR microcontrollers*/

#define          F_CPU          8000000
/*Defines a macro for the delay.h header file. F_CPU is the microcontroller frequency value for the delay.h header file. Default value of F_CPU in delay.h header file is 1000000(1MHz)*/

#include<util/delay.h>
/*Includes delay.h header file which defines two functions, _delay_ms (millisecond delay) and _delay_us (microsecond delay)*/

#include<avr/usart.h>
/*Includes usart.h header file which defines different functions for USART. USART header file version is 1.1*/

int main(void)
{

DDRB=0xff;
/*All the 8 pins of PortB are declared output (LED array is connected)*/

char usart_received_data;
/*Variable declaration*/

usart_init();
/*USART initialization*/

usart_string_transmit(“ABLab Solutions”);
/*Transmits string to PC*/

usart_data_transmit(0x0d);
/*Transmits Carriage return to PC for new line*/

usart_string_transmit(“www.ablab.in”);
/*Transmits string to PC*/

usart_data_transmit(0x0d);
/*Transmits Carriage return to PC for new line*/

usart_string_transmit(“Press any key from keyboard:”);
/*Transmits string to PC*/

usart_data_transmit(0x0d);
/*Transmits Carriage return to PC for new line*/

/*Start of infinite loop*/
while(1)
{

usart_received_data=usart_data_receive();
/*Microcontroller receives data from PC */

PORTB=usart_received_data;
/*Data received from PC is displayed in LED array*/

usart_data_transmit(0x0d);
/*Transmits Carriage return to PC for new line*/

}

}
/*End of Program*/

Connection Guide

The step-by-step connection guide for PC to ATmega16 Communication with LED Display is as follows:

  • Insert the DC Pin of 12V, 1A DC Adapter to the DC Socket of AVR Trainer Board-100.

    Steps - 1 ( 0f 9 )

  • Connect PortB header with LED header in AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

    Steps - 2 ( 0f 9 )

  • Connect the RS-232 Driver header of RS-232 Driver with PortD header of AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

    Steps - 3 ( 0f 9 )

  • Connect the DB-9 Connector of USB to Serial Cable to the DB-9 Connector of RS-232 Driver and USB Connector of USB to Serial Cable to PC/Laptop USB port.

    Steps - 4 ( 0f 9 )

  • Connect the ISP header of AVR Trainer Board-100 with AVR USB Programmer header of AVR USB Programmer with a 10 to 10 FRC Female Connector.

    Steps - 5 ( 0f 9 )

  • Connect the AVR USB Programmer to the PC/Laptop's USB Port directly or with the help of USB AM-FM Cable.

    Steps - 6 ( 0f 9 )

  • Download the PC to ATmega16 Communication with LED Display Hex file to AVR Trainer Board-100 with the help of SinaProg Hex downloader and AVR USB Programmer.

    Steps - 7 ( 0f 9 )

  • Open the Real Term software in PC/Laptop and do the required settings.

    Steps - 8 ( 0f 9 )

  • Switch on the power with the help of Power Switch of AVR Trainer Board-100.

    Steps - 9 ( 0f 9 )

  • Insert the DC Pin of 12V, 1A DC Adapter to the DC Socket of AVR Trainer Board-100.

    Steps - 1 ( 0f 9 )

  • Connect PortB header with LED header in AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

    Steps - 2 ( 0f 9 )

  • Connect the RS-232 Driver header of RS-232 Driver with PortD header of AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.

    Steps - 3 ( 0f 9 )

  • Connect the DB-9 Connector of USB to Serial Cable to the DB-9 Connector of RS-232 Driver and USB Connector of USB to Serial Cable to PC/Laptop USB port.

    Steps - 4 ( 0f 9 )

  • Connect the ISP header of AVR Trainer Board-100 with AVR USB Programmer header of AVR USB Programmer with a 10 to 10 FRC Female Connector.

    Steps - 5 ( 0f 9 )

  • Connect the AVR USB Programmer to the PC/Laptop's USB Port directly or with the help of USB AM-FM Cable.

    Steps - 6 ( 0f 9 )

  • Download the PC to ATmega16 Communication with LED Display Hex file to AVR Trainer Board-100 with the help of SinaProg Hex downloader and AVR USB Programmer.

    Steps - 7 ( 0f 9 )

  • Open the Real Term software in PC/Laptop and do the required settings.

    Steps - 8 ( 0f 9 )

  • Switch on the power with the help of Power Switch of AVR Trainer Board-100.

    Steps - 9 ( 0f 9 )

Downloads

PC to ATmega16 Communication with LED Display C File
  • 44 downloads
  • 2 Kb
PC to ATmega16 Communication with LED Display Circuit Diagram
  • 23 downloads
  • 227 Kb
PC to ATmega16 Communication with LED Display Hex File
  • 27 downloads
  • 1 Kb
USART Header File v1.0
  • 592 downloads
  • 2 Kb

Comments