Sunday, August 28, 2022

IR remote control library for AVR microcontrollers

A remote controller is a device that... You probably have one near you so I'll skip the introduction. This library can be used for sending or receiving remote controller codes. The supported protocols at the moment depends on what remote controllers I had in the house and all 4 of them used NEC and RC-5.

The IR library is very easy to use and it needs a 16-bit timer for both sending and receiving. I have chose Timer 1 for this purpose. Before diving into the code, let's see how a remote controller works and take a closer look at their protocols.




How a remote controller works

A remote control is using optical communication to send wireless data to a receiver device. For this purpose, the infrared light was chosen. The data is transmitted on top of a carrier frequency that is usually 38kHz. There are many schemes of encoding the data because there are many manufacturers of consumer products. The most commonly used protocols are NEC, RC-5, RC-6, Sony. 

Sunday, August 7, 2022

UART library for AVR microcontrollers

A highly customizable UART library that can also be called USART since it has the option for synchronous transfer mode. It can work with transmit and receive buffers down to 1 byte in size, making it suitable for devices with small memory. It was mainly made for ATmega328PB.

AVR microcontrollers have support for both UART and USART modes. USART stands for Universal Synchronous Asynchronous Receiver Transmitter. Notice that UART lacks the S that stands for Synchronous.

UART is a type of serial interface, as opposed to a parallel interface. A parallel interface can work at higher speeds but the disadvantage is that it needs multiple input/output lines. Other examples of serial interfaces are SPI and I2C.

UART library for AVR microcontrollers using interrupts


  • Custom Baud rate
  • Asynchronous or synchronous modes
  • Supports serial frames with 5, 6, 7, 8, or 9 data bits
  • Odd, even or no parity
  • Error detection
  • Multi-processor communication mode used to address multiple devices on the same serial bus
  • Double speed asynchronous communication mode

Thursday, August 4, 2022

Tutorial on how to program an AVR ATmega328PB microcontroller using Atmel Studio and a bootloader

In this tutorial you will be learning how to use Microchip Studio (previously known as Atmel Studio) to program an AVR microcontroller over UART using the Optiboot bootloader. The hardware necessary is very inexpensive. All you need is an ISP (In System Programming) module such as USBTinyISP (around 3$) and an USB to Serial adapter that is around the same price and you can even build it yourself if you wish.