Society of Robots - Robot Forum
Software => Software => Topic started by: wecool44 on December 13, 2011, 08:39:52 PM
-
I just made an attachment for my Axon that allows it to be connected to a breadboard. I wanted to program it in AVR-GCC(No additional libraries) and the program built correctly. I uploaded it to the Axon, and nothing happens. This code is meant to flash an LED connected to C0. And yes, I did put a resistor before the LED. Here is the code:
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
main() {
DDRC = 0b10000000;
while(1) {
PORTC = 0b10000000;
_delay_ms(50);
PORTC = 0b00000000;
_delay_ms(50);
}
}
-
Just in case, do you have the LED pointing the right direction?
Also, increase the delay to 500. You have it faster than the eye can see :P
-
I tried that, and still nothing happened. I also tried switching the LED's direction, and that didn't do anything. Attached is a picture of the board
-
This code is meant to flash an LED connected to C0.
I noticed your code is changing the bit for C7, not C0 :P
Bits are ordered as DDRC = 0b76543210;
Try this code below. It'll make keeping track of bits easier.
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
//define port functions; example: PORT_ON( PORTD, 6);
#define PORT_ON( port_letter, number ) port_letter |= (1<<number)
#define PORT_OFF( port_letter, number ) port_letter &= ~(1<<number)
DDRC = 0b11111111; //configure ports for output
main()
{
while(1)
{
PORT_ON(PORTC,7);
_delay_ms(500);
PORT_OFF(PORTC,7);
_delay_ms(500);
}
}
In the end, you're going to find yourself writing your own libraries as your code gets more complicated. It's best to just give in and use WebbotLib :P