EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / This is the at8ports.h HEADER

This is the at8ports.h HEADER

|

Microcontroller › AVR › SMS operated robot › This is the at8ports.h HEADER

June 8, 2013 at 3:28 pm #9916
SOUBHIK KUMAR DEY
Participant

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;

}

RSS Recent Posts

  • compile errors April 22, 2026
  • Quick Tip: Handling CH340 Driver Issues on Uno SMD Clones April 22, 2026
  • My Advanced Realistic Humanoid Robots Project April 22, 2026
  • Getting into an LED bulb April 21, 2026
  • understanding of resonance in time domain April 21, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise