Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need a help for my project

Status
Not open for further replies.

megha a s

Newbie level 2
Joined
Jan 9, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,296
hello...
its my first project using atmel series..
i request ur kind suggestions about good tutorial for atmega learning....
plz....
 

Hi,

Spend some time learning C programming, then download a compiler and go from there. You can practice your C skills by using 'gcc'.
Once you've learnt how to program in C, you'll be able to control pins and read inputs very easily on the ATmega series.
Here is an example:
Code:
#include <iom169.h> /* replace with the correct header file */
#include <intrinsics.h>
#include <avr_macros.h>
#include <stdio.h>

// bits
#define BIT0 0x01
#define BIT1 0x02
#define BIT2 0x04
#define BIT3 0x08
#define BIT4 0x10
#define BIT5 0x20
#define BIT6 0x40
#define BIT7 0x80

// port D stuff
#define LED        BIT6
#define BUTTON     BIT7

// inputs
#define SWITCH_ON (PIND & BUTTON) == 0
#define SWITCH_OFF (PIND & BUTTON) != 0

// outputs
#define LED_ON PORTD |= LED
#define LED_OFF PORTD &= ~LED

int
main(void)
{
    DDRD=BIT6; // Set pin 6 as output, all others as inputs
    
    while(1)
    {
      if (SWITCH_ON)
        LED_ON;
      else
        LED_OFF;
    }
    
    return(0); // this line will never execute
}

Saved you a whole load of time looking for atmega tutorials.. you just need to learn C.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top