Sunday, June 26, 2016

ATMEGA328P UART0

CONNECTION CONNECT RX AND TX TO TX AND RX OF OTHER DEVICE

//This define the system frequency
#define F_CPU 16000000UL

//Including the required files
#include <avr/io.h>
#include <util/delay.h>

Sunday, June 12, 2016

LCD INTERFACING 8 BIT MODE

Circuit connection is 
RS => PB0
RW => PB1
EN => PB2
D0-D3 =>PORTD 0 TO 3
D4-D7 => PORTC 0 TO 3

READING A GPIO

Circuit diagram includes using PORTB5 as output to toggle a LED and PORTC5 for input with button connected to ground.

BLINKING A LED

Circuit diagram includes connecting a LED with resistor in series in PORTB5, its digital 13 on Aruino.

Blink LED method 1

#define F_CPU 16000000

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
   
DDRB |= (1 << PORTB5);
    while (1)
    {
PORTB |= (1 << PORTB5);
_delay_ms(200);
PORTB &= ~(1<< PORTB5);
_delay_ms(100);

    }
}