Society of Robots - Robot Forum

Software => Software => Topic started by: robotmaniac on November 06, 2012, 04:25:43 PM

Title: LED CODE Please help
Post by: robotmaniac on November 06, 2012, 04:25:43 PM
Could some on tell me what is worng with this code?
#include <avr/io.h>
int main(void)
/*0d004321ba*/
{
   DDRD = 0D00000001;//Setting port 0 to oput
    PORTD = 0D00000001;//setting port 0 high

   while(1){}
   }
cause i get this
../LED_matrix_v1.c:5:9: error: invalid suffix "D00000010" on integer constant
../LED_matrix_v1.c:6:11: error: invalid suffix "D00000010" on integer constant
Im just trying to light up 8 LEDs using multiplexing but i want to turn on only port PD0 isnt that the way??
Title: Re: LED CODE Please help
Post by: jkerns on November 06, 2012, 04:34:40 PM
0D? not 0b?

What compilier are you using?
Title: Re: LED CODE Please help
Post by: robotmaniac on November 06, 2012, 04:49:06 PM
Im using AVR but I wanted to turn on the portD for the ATmega 8
Title: Re: LED CODE Please help
Post by: stridera on November 06, 2012, 07:35:28 PM
You definitely want to use B not D.  B for Binary.

B00000001

Refer to this:  http://www.arduino.cc/en/Reference/IntegerConstants (http://www.arduino.cc/en/Reference/IntegerConstants)
Title: Re: LED CODE Please help
Post by: robotmaniac on November 06, 2012, 07:48:58 PM
oo thaks now how can i creat a patern?
Title: Re: LED CODE Please help
Post by: stridera on November 06, 2012, 08:57:49 PM
If you want to send data serially, you'll need a serial converter.  This will take 1-2 pins from the arduino and translate that to x pins, depending on the converter.  (2 pins for a lock.)   (Plenty of information on how to do this across the web.)
Title: Re: LED CODE Please help
Post by: jkerns on November 07, 2012, 10:08:34 AM
This guy: http://newbiehack.com/MicrocontrollerTutorial.aspx (http://newbiehack.com/MicrocontrollerTutorial.aspx)
does a decent job of walking you through turning on an LED, making it blink, playing games with it, etc. in a step by step process.
Title: Re: LED CODE Please help
Post by: robotmaniac on November 11, 2012, 08:32:06 PM
thanks guys but when I turn all the leds the last one stays off. I created an 2x4 but when I turn only that one it turns one.
Title: Re: LED CODE Please help
Post by: stridera on November 11, 2012, 08:34:10 PM
If you're using pins on the Arduino, make sure you're not using the TX/RX pins.  (They're for the serial connection and if you have it connected to the computer to power it, they'll always be on.