Go Down

Topic: 8 blinking leds (Read 156 times) previous topic - next topic

shreerajshah95

i am trying to make program of 8 blinking using port manipulation technique. I have used port B pin (6-13). I am getting an error quoted " DDRB was not declared in this scope". I have attached the image. If any one can help me out with it, it would be great help :)

Code: [Select]

void setup() {
  // put your setup code here, to run once:
DDRB = DDRB| B111111;
}
void loop() {
  // put your main code here, to run repeatedly:
PORTB = B111111;// turn the LED on (HIGH is the voltage level) 
  delay(1000); // wait for a second

PORTB = B000000;    // turn the LED off by making the voltage LOW
 delay(1000);              // wait for a second

}

UKHeliBob

I see that you are compiling the code for a Due.  Does it have the same ports as the 328 based boards ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

shreerajshah95

Yes, I have been using Due. And no, it has more number of ports than 328 based boards. Can you help me out with it??

AWOL

The Due is a different processor (ARM-based) to the 328 boards (AVR) - you cannot simply use the same port manipulation registers.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

shreerajshah95

Then what should be I doing if I don't want to increase my code lines and still control all the pins using less function?

AWOL

If I were that desperate, I'd be picking apart "wiring_digital.c" and "wiring_digital.h" in "sam/cores/arduino"

I'm not that desperate.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

UKHeliBob

Then what should be I doing if I don't want to increase my code lines and still control all the pins using less function?
How important is it that the LEDs turn on and off at exactly the same time ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

shreerajshah95

It is very important for led's to blink at the exact time as expected. Is there any alternative for it in 'Arduino Due' other than the code i wrote??
How important is it that the LEDs turn on and off at exactly the same time ?

UKHeliBob

Quote
It is very important for led's to blink at the exact time as expected
What is it that reacts to the blinking of the LEDs ?

Why not just use one output, digitalWrite() and 8 transistors to turn on the LEDs or output a byte with a value of 255 to a shift register and do it that way ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy