Embedded Systems Tutorial

AVR Microcontroller

8051 Microcontroller

8085 Microprocessor

8086 Microprocessor

8255 Microprocessor

Embedded Systems Practice

AVR | USART Home Automation

In this tutorial, we will learn about the Universal Synchronous and Asynchronous Serial Receiver and Transmitter (USART) Home Automation. By Suryaveer Singh Last updated : May 12, 2023

Features of USART

The Universal Synchronous and Asynchronous serial Receiver and Transmitter (USART) is a highly flexible serial communication device. The main features are:

  • Full Duplex Operation (Independent Serial Receive and Transmit Registers)
  • Asynchronous or Synchronous Operation
  • Master or Slave Clocked Synchronous Operation
  • High-Resolution Baud Rate Generator
  • Supports Serial Frames with 5, 6, 7, 8, or 9 Data Bits and 1 or 2 Stop Bits
  • Odd or Even Parity Generation and Parity Check Supported by Hardware
  • Data Overrun Detection
  • Framing Error Detection
  • Noise Filtering Includes False Start Bit Detection and Digital Low Pass Filter
  • Three Separate Interrupts on TX Complete, TX Data Register Empty, and RX Complete
  • Multi-processor Communication Mode
  • Double Speed Asynchronous Communication Mode

These are some of the features of USART, we would now lean to create a program in which we would use Bluetooth technology to open and close a LED bulb. In our program, we would take a variable X, such that if X=A our bulb will glow and if X=B the bulb will stop glowing.

AVR | USART Home Automation: Example

In the similar we can also use a fan instead of LED, then we would be controlling our Fan to start or stop.


#include <avr/io.h>

void usart_string(char*);

int main(void)
	char x;
	DDRA = 0x01;
	UBRRL= 51;
	UCSRB= 0x18;
	UCSRC= 0x86;


		else if(x=='B')

void usart_string(char*p)


  • Write all the header files as written above.
  • Take a variable X which will decide whether our bulb will be ON or OFF.
  • DDRA=0x01 indicates that the Led bulb is connected.
  • UBRRL=51; indicates that the baud rate is set to 9600.
  • UCSRB=0x18 means Rx and Tx are enabled.
  • The usart_string will print the word written inside it.
  • Inside the while loop, we have written our bulb glowing condition such that when A is received the LED will glow and when B is received the LED bulb will stop glowing.


It is the rate at which the information is processed/transferred to the communication channel.

Calculation of BAUD RATE

Calculation of BAUD RATE

Where, fOSC is "System Oscillator Clock Frequency".


USART Simulation

Simulation Explanation

  • Select the following components:
    1. Atmega16
    2. LED Red
    3. From virtual instruments mode select a VIRTUAL TERMINAL
  • Add the components as shown in the figure.
  • Double click on ATmega16 and make its speed as 8000000 and upload the hex file in it.
  • When we will start the simulation a screen will appear that would be our simulation for a Bluetooth screen.
  • Typing A will glow the bulb and typing B will stop the bulb from glowing.

Comments and Discussions!

Load comments ↻

Copyright © 2024 www.includehelp.com. All rights reserved.