AVR | USART Home Automation

In this article, we are going to learn about the Universal Synchronous and Asynchronous serial Receiver and Transmitter (USART) Home Automation.
Submitted by Suryaveer Singh, on August 08, 2018

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.

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


  • 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!

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.