Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
owned! but seriously, the atmega8 has approx 20 I/O 14 of them digital, 6 analogue. all of them can be used to turn on and off an led. NOTE: atmega8 and atmega168 are the same except for some more memory in the 168.the only pins you cant use are xtal1 and xtal2 (9&10)gnd(8 & 22), vcc(7), aref(21), avcc(20) and reset(1) the rest are I/O meaning you can control 20 leds but that's with no inputs of coarse.
//************CONFIGURE PORTS************//configure ports for input or output - specific to ATmega8void configure_ports(void) { DDRC = 0x00; //configure all C ports for input PORTC = 0x00; //make sure pull-up resistors are turned off DDRD = 0xFF; //configure all D ports for output DDRB = 0xC7; //configure B ports 0, 1, 2, 6, 7 for output (google search '0b11000111 to hex') }//***************************************
int reading = (PORTB | (1<<4)) >>4;
DDRB = 0x1F; //0x1F is hexadecimal for binary 00011111