Thursday 22 October 2015

computer operating LED

COMPUTER OPERATING LED

we can control real world electronics elements using computer with .net s/w. this project is mainly used for Home automation.



         
AVR ATMEGA 16 CODE
/*
 * uart_suria.c
 *
 * Created: 8/12/2015 9:50:06 AM
 *  Author: suriasarath
 */

#include <avr/io.h>
#include <inttypes.h>
#define F_CPU 8000000UL

char data;
void USARTiint(uint16_t UBRR_VALUE)
{
    UBRRL= UBRR_VALUE;
    UBRRH=(UBRR_VALUE>>8);
    UCSRC=(1<<URSEL)|(3<<UCSZ0);
    UCSRB=(1<<TXEN)|(1<<RXEN);
}
char usart_readchar()
{
    while(!(UCSRA &(1<<RXC)))
    {
       
    }   
    return UDR;
   
}
void usart_writechar(char data)
{
    while(!(UCSRA & (1<<UDRE)))
    {
       
    }
    UDR=data;
}
int main(void)
{
    char data;
    USARTiint(26);
   
    while(1)
    {
        DDRA=0xff;
        data=usart_readchar();
        if (data=='a')
        {
            PORTA|=1<<PA0;
            usart_writechar('s');
        }   
        if(data=='q')
        {
            PORTA&=~1<<PA0;
            usart_writechar('d');
        }
   
             
    }
}
Its normal uart code then we write code for vb.net so we can connect using Computer serial port