Microcontroller › AVR › SMS operated robot › This is the at8ports.h HEADER
This is the at8ports.h HEADER FILE to define the Input and Output ports.
#include <avr/io.h>
#include <avr/inttypes.h>
#define DDRB_OUT(x) DDRB = DDRB | 0x01<<x
#define DDRB_IN(x) DDRB = DDRB & ~(0x01<<x)
#define DDRC_OUT(x) DDRC = DDRC | 0x01<<x
#define DDRC_IN(x) DDRC = DDRC & ~(0x01<<x)
#define DDRD_OUT(x) DDRD = DDRD | 0x01<<x
#define DDRD_IN(x) DDRD = DDRD & ~(0x01<<x)
#define PB_ON(x) PORTB = PORTB | 0x01<<x
#define PB_OFF(x) PORTB = PORTB & ~(0x01<<x)
#define PC_ON(x) PORTC = PORTC | 0x01<<x
#define PC_OFF(x) PORTC = PORTC & ~(0x01<<x)
#define PD_ON(x) PORTD = PORTD | 0x01<<x
#define PD_OFF(x) PORTD = PORTD & ~(0x01<<x)
uint8_t PB_IN(uint8_t pin)
{
if((PINB & (0x01<<pin))==0)
return 0;
else
return 1;
}
uint8_t PC_IN(uint8_t pin)
{
if((PINC & (0x01<<pin))==0)
return 0;
else
return 1;
}
uint8_t PD_IN(uint8_t pin)
{
if((PIND & (0x01<<pin))==0)
return 0;
else
return 1;
}
void init_pwm()
{
TCCR1A|=(1<<WGM10)|(1<<COM1A1)|(1<<COM1B1);
TCCR1B=0x04;
DDRB = DDRB | 0x06;
}