go away spammer

Author Topic: LED CODE Please help  (Read 2452 times)

0 Members and 1 Guest are viewing this topic.

Offline robotmaniacTopic starter

  • Jr. Member
  • **
  • Posts: 40
  • Helpful? 0
LED CODE Please help
« 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??
Learning from what I can...

Offline jkerns

  • Robot Overlord
  • ****
  • Posts: 270
  • Helpful? 12
Re: LED CODE Please help
« Reply #1 on: November 06, 2012, 04:34:40 PM »
0D? not 0b?

What compilier are you using?
I get paid to play with robots - can't beat that with a stick.

http://www.ltu.edu/engineering/mechanical/bachelor-science-robotics-engineering.asp

Offline robotmaniacTopic starter

  • Jr. Member
  • **
  • Posts: 40
  • Helpful? 0
Re: LED CODE Please help
« Reply #2 on: November 06, 2012, 04:49:06 PM »
Im using AVR but I wanted to turn on the portD for the ATmega 8
Learning from what I can...

Offline stridera

  • Jr. Member
  • **
  • Posts: 28
  • Helpful? 0
  • Software Engineer, Author, Hacker.
Re: LED CODE Please help
« Reply #3 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

Offline robotmaniacTopic starter

  • Jr. Member
  • **
  • Posts: 40
  • Helpful? 0
Re: LED CODE Please help
« Reply #4 on: November 06, 2012, 07:48:58 PM »
oo thaks now how can i creat a patern?
Learning from what I can...

Offline stridera

  • Jr. Member
  • **
  • Posts: 28
  • Helpful? 0
  • Software Engineer, Author, Hacker.
Re: LED CODE Please help
« Reply #5 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.)

Offline jkerns

  • Robot Overlord
  • ****
  • Posts: 270
  • Helpful? 12
Re: LED CODE Please help
« Reply #6 on: November 07, 2012, 10:08:34 AM »
This guy: 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.
I get paid to play with robots - can't beat that with a stick.

http://www.ltu.edu/engineering/mechanical/bachelor-science-robotics-engineering.asp

Offline robotmaniacTopic starter

  • Jr. Member
  • **
  • Posts: 40
  • Helpful? 0
Re: LED CODE Please help
« Reply #7 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.
Learning from what I can...

Offline stridera

  • Jr. Member
  • **
  • Posts: 28
  • Helpful? 0
  • Software Engineer, Author, Hacker.
Re: LED CODE Please help
« Reply #8 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.

 


Get Your Ad Here