Oct 5, 2009
How To to build an ISP for Atmega 128
Aug 19, 2008
code for line following robot in atmega8
Now this is the source code for the line following Robot.
this will work for atmega8
int main(void)
{
DDRB|=0x0F;
PORTB=0x0F6;
while(1)
{PORTB|=0x06;
PORTB&=0x0F9;
}
}
with the above code the bot will move only in the straight path now if you want it to move in different directions just change the code in the while loop
You might be also interested in:
:: centigrade (celsius) to fahrenheit calculation for 8086 Assembly Language
:: Data transfer instructions of 8086 microprocessor
:: 8085 Microprocessor simulator for linux
::Interfacing pic microcontroller with LCD
Jul 28, 2008
Interfacing Multimedia card with ATMega 128
hears some routine. Take a Look on them
void SPI_init(void)
{
DDRB |= (1 << SPICS); // 0 set port B SPI chip select to output
DDRB |= (1 << SPICLK); // 1 set port B SPI clock to output
DDRB |= (1 << SPIDO); // 2 set port B SPI data out to output
DDRB &= ~(1 << SPIDI); // 3 set port B SPI data input to input
SPCR = (1 << SPE) | (1 << MSTR); //pg#168(391)
SPICS_ON();
}
char Command(char befF, int AdrH, int AdrL, char CRC )
{ // sends a command to the MMC
SPI(0xFF);
SPI(befF);
SPI((AdrH >> 8));
SPI(AdrH);
SPI((AdrL >> 8));
SPI(AdrL);
SPI(CRC);
SPI(0xFF);
return SPI(0xFF); // return the last received character
}
unsigned char SPI(unsigned char mydata)//transmit through SPI data out
line(MOSI)
{
//unsigned char Rx_SPDR=0xDC, Rx;
SPDR = mydata; //1 Byte data
while(!(SPSR & (1<<SPIF))) // wait for complete transmission
;
//printf("\r\nRx_SPDR = 0x%X", Rx_SPDR);
//Rx=SPDR;
//printf("\r\nRx_SPDR = 0x%X", Rx_SPDR);
return SPDR; //return the received value of SPDR
}
int Read_from_MMC(void) { // send 512 bytes from the MMC via the serial port
int i;
// 512 byte-read-mode
if (Command(0x51,0,512,0xFF) != 0)
{
printf("MMC: read error 1 ");
return 0;
}
// wait for 0xFE - start of any transmission
// ATT: typecast (char)0xFE is a must!
while(SPI(0xFF) != (char)0xFE);
for(i=0; i < 512; i++)
{
while(!(UCSR0A & (1 << UDRE0))); // wait for serial port
/*Here we are transmitting 0xFF through MOSI and then assigning the received
character to USART Data Register*/
UDR0 = SPI(0xFF); // send character
}
// at the end, send 2 dummy bytes
SPI(0xFF); // actually this returns the CRC/checksum byte
SPI(0xFF);
return 1;
}
You might be also interested in:
:: Assembly Language Programs for Multiplication and Division
:: Assembly Language Programs on array of Hexadecimal numbers
:: Assembly Language Programs on strings
May 10, 2008
Serial Port interfacing with atmega
.include"m32def.inc"
.org 0000
rjmp main
main: ldi r16,low(ramend)
out SPL,r16
ldi r16,high(ramend)
out SPH,r16
ldi r18,0x00
out UBRRH,r18
ldi r18,0x19 ;setting baud rate of 2400 for 1MHZ
out UBRRL,r18
ldi r19,0x18
out UCSRB,r19 ;enabling RX & TX bits
ldi r19,0x86
out UCSRC,r19 ;setting aychronous mode with 1 stop
;& 1start bit & no parity
again: rcall usart_rx
rcall usart_tx
rjmp again
usart_rx: sbis UCSRA,RXC
rjmp usart_rx
in r17,UDR
ret
usart_tx: sbis UCSRA,UDRE
rjmp usart_tx
out UDR,r17
ret
;*************************
and set the settings in hyper terminal as
baud rate:2400
flow control:none
;********
You might be also interested in:
:: centigrade (celsius) to fahrenheit calculation for 8086 Assembly Language:: Data transfer instructions of 8086 microprocessor