Newbie and simple Digital Outputs

09 Mar 2011

Hi everyone, I've wired up 8 leds on digital outputs pins 10 - pins 17, with a very simple program that turns on the first 4 led's in sequence i.e. turn on pin 10 light led connected for 1sec, turn off pin 10, turn on pin 11 light led connected for 1 sec, turn off pin 11 etc etc. What's happening is that when pin 13 turns on (remember the program only turns 4 leds on not the 8 connected)pins 14, 15, 16 and 17 all turn on and light the led's for 1 sec. Is this something in the hardware being pulled down when pin 13 goes high and conducts? Regards Degs

09 Mar 2011

I don't think this should be happening. Are you sure you you connected every led to a single pin? Can you show us your code? (use tags <<code>> <</code>> for proper formatting).

09 Mar 2011

also, a simple circuit diagram of how you connected it up would be useful.

09 Mar 2011

Yes the circuit really is very simple with each led connected to an individual pin and a common 0v for all led's. I'll post the code later when I'm home.

09 Mar 2011
  1. include "mbed.h"

DigitalOut led1(p10);assign pin 10 as first digital output DigitalOut led2(p11); DigitalOut led3(p12); DigitalOut led4(p13);

int main() { while(1) { led1 = 1;turn on first led assigned to pin10 wait(0.5); led1 = 0;turn off first led assigned to pin10 wait(0.5); led2 = 1; wait(0.5); led2 = 0; wait(0.5); led3 = 1; wait(0.5); led3 = 0; wait(0.5); led4 = 1; wait(0.5); led4 = 0; wait(0.5); } }

09 Mar 2011

#include "mbed.h"

DigitalOut led1(p10); <</code>> DigitalOut led2(p11); <</code>> DigitalOut led3(p12); <</code>> DigitalOut led4(p13); <</code>>

int main() { <</code>> while(1) { <</code>> led1 = 1; wait(0.5); led1 = 0; wait(0.5); <</code>> led2 = 1; wait(0.5); led2 = 0; wait(0.5); <</code>> led3 = 1; wait(0.5); led3 = 0; wait(0.5); <</code>> led4 = 1; wait(0.5); led4 = 0; wait(0.5); <</code>> } <</code>> } <</code>>

09 Mar 2011

Oh well that looks terrible LOL how do you get your code looking respectable in a post?

09 Mar 2011

Ok so now I expanded the simple program to turn on digital outputs pins 10 to pins 17 turning on and off sequentially 8 leds. This time as the sequence progresses and it gets to pin 13 to pin 16 none of the leds come on only pin 17 turns on, then reverts to pin 10 to continue the cycle? Is this a hardware fault?

09 Mar 2011

The <<code>> and <</code>> tags should be at the start of a line on their own [edit: oh and one start and one stop, not around every piece of code]].

09 Mar 2011

I think this is what you meant:-

#include "mbed.h"

DigitalOut led1(p10); 
DigitalOut led2(p11); 
DigitalOut led3(p12); 
DigitalOut led4(p13);

int main() { 
    while(1) { 
        led1 = 1; 
        wait(0.5); 
        led1 = 0; 
        wait(0.5);
        led2 = 1; 
        wait(0.5); 
        led2 = 0; 
        wait(0.5); 
        led3 = 1; 
        wait(0.5); 
        led3 = 0; 
        wait(0.5); 
        led4 = 1; 
        wait(0.5); 
        led4 = 0; 
        wait(0.5); 
    } 
}
09 Mar 2011

Thanks for that Andy I'll bear that in mind next time.

09 Mar 2011
09 Mar 2011

Why is Vin connected to Vout? That's a big no-no...

10 Mar 2011

Thanks for that a really fundamental mistake on my part, I've completely misunderstood the circuit. I'll re-wire my circuit tonight and see what happens.

Thanks again.

10 Mar 2011

Another quick one in that diagram the leds are the wrong way round as you have cathode to the resistor and anode to the ground so they wont light up

ensure resistor values are correct to avoid overdriving leds or port pin 220 ohm should do nicely

place anode to the resistor and cathode to ground and all should be okay

have a look at page 2 of the reference manual how the mbed board does it http://mbed.org/media/uploads/chris/lpc1768-refdesign-schematic.pdf

Chris

10 Mar 2011

Hi everyone, just like to say a big thank you and for your patience and all the advice. I've solved it..................it was hardware in the end. I removed the mbed from the mbed developer board I had purchased with it (I've obviously had it plugged in the wrong way round - no indication on board where pin1 is) and plugged into a simple plugin board and it works fine now. I've taken all your advice and ready for playing further.

11 Mar 2011

What do people use to draw schematics with for posting on here please?

Has anyone used the magnevation dual driver board for driving dc motors?

11 Mar 2011

Fritzing is pretty easy to use if you are new at it. Eagle is quite good as well but a little more complicated.

11 Mar 2011

I use ubuntu 10.10 on my laptop and just read about how to download fritzing so I'll give a try and see what happens thanks for the info.

11 Mar 2011

Tried to run Fritzing but the shell program wouldnt run so I've downloaded gEDA looks very promising anyone tried it on Ubuntu for schematics?