Society of Robots - Robot Forum
Software => Software => Topic started 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??
-
0D? not 0b?
What compilier are you using?
-
Im using AVR but I wanted to turn on the portD for the ATmega 8
-
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)
-
oo thaks now how can i creat a patern?
-
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.)
-
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.
-
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.
-
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.