1. ## To generate an output on Breadboard using parallel port.

Hello guys.
I am a low programmer I gont know too much about programming so I need your help.
I have to generate a program which turn on and turn off 10 LEDS in ascending order on bread board using PARALLEL PORT. The problem is parallel port only give 8 bits and I have to get result on 10 bits. I have used DEMULTIPLEXER (74HC138N) to get 10 bits. I have joine D0-D8 from LEDS D9 from demultiplexer and then 3 LEDS from DEMULTIPLEXER's leg.
I hope someone will come up with a working program.

2. That someone needs to be you -- you aren't going to learn otherwise. Read the site's homework policy. Then, make an attempt, post your code (read this first) and ask specific questions. You will find us much more willing to help.

Also, it often helps if you give us the uC you're using and any relevant circuit schematics for problems like this.

3. You are going to have to break this problem into hardware and software parts.

The software needs to output values ?,?,? in order to the output port.

What is the hardware? Note, we are NOT assuming PCs if PC state that.

Tim S.

4. Originally Posted by chip manual page
74HC138; 74HCT138
3-to-8 line decoder/demultiplexer; inverting

1. The 74HC138; 74HCT138 decoder accepts three binary weighted address inputs (A0, A1
and A3) and when enabled, provides 8 mutually exclusive active LOW outputs (Y0 to Y7).

2. The 74HC138; 74HCT138 features three enable inputs: two active LOW (E1 and E2) and
one active HIGH (E3). Every output will be HIGH unless E1 and E2 are LOW and E3 is
HIGH.
Para 1 takes up 3 bits from your parallel port.
Para 2 takes up 1 bit from your parallel port.
For that, you can drive 8 LEDs.

You have 4 bits left to drive 2 more LEDs.

5. Salem I am going for the first step that is I will take 3 inputs and generate 8 outputs and 2 more outputs from the parallel port.
I created this program for 8 leds directly connected from parallel port and giving me 8 bits result. I'll be thankful to you guys if you guys can help me out to generate 10 bits result.
Here is my program for 8 bit.

# include <stdio.h>
void main ()
{
int leds[9] = {0,1,2,4,8,16,32,64,128};
int i=1;
for (i=0;i<9;i++)
{
printf("\n%d",leds[i]);
outportb(0x378,leds[i]);
sleep(1);
}
}

6. You seem to have mastered [b][/b] tags for code, how about actually using [code][/code] tags instead?

Also, you need to SHOW us your hardware circuit diagram, showing how you wired up your 74HC138 to your parallel port pins.

I'm not going to guess you put it on pins 4 to 7 (and write a program for it), only for you to come back saying it still doesn't work.

7. Originally Posted by hamxakhan
Salem I am going for the first step that is I will take 3 inputs and generate 8 outputs and 2 more outputs from the parallel port.
I created this program for 8 leds directly connected from parallel port and giving me 8 bits result. I'll be thankful to you guys if you guys can help me out to generate 10 bits result.
Here is my program for 8 bit.

Code:
```#include <stdio.h>
void main ()
{
int leds[9] = {0,1,2,4,8,16,32,64,128};
int i=1;
for (i=0;i<9;i++)
{
printf("\n%d",leds[i]);
outportb(0x378,leds[i]);
sleep(1);
}
}```
At this point it would likely be easier to redo your breadboard with a 74HC154 which is 4 lines in and 16 mutually exclusive outputs. You would be using only 4 bits of your port and it would be much easier to drive software wise... If you only need 10 leds, just leave a few open outputs and test your output values in software to be less than or simply use %10 to have the output value wrap around from 0 to 9...

Code:
`outportb(0x378, leds[i] % 10);`
I believe the 74HC154 can be had for less than \$2.00cdn. so that shouldn't be a problem.

8. You didn't read the link I posted that discusses code tags, did you...please put your code in code tags and indent it properly.

Your code doesn't allow multiple bits on your parallel port to be active at the same time, which means you can't actually address your demuxer in a meaningful way. You wan't to use only 3 bits to generate numbers 0-7. The 3 bits represent A0-A2, and the output numbers Y0-7. If you're familiar with binary numbers, then you realize that binary to decimal gives something like:
000 = 0 <-- LED 0 on Y0
001 = 1 <-- LED 1 on Y1
010 = 2
011 = 3
...
111 = 7 <-- LED 7 on Y7

Those 3 output bits will allow you to address the 8 outputs of your demuxer. You can use the 3 low-order bits (call them b0 - b2) of your parallel port data for this. You can then use b3 and b4 for the other two LEDs, and b5 for your enable. You could use an array like you are currently doing to map LED numbers to parallel port outputs. For example, to turn on LED 3, you would give the following output (where x means "don't care"):
x x 1 0 0 0 1 1

Convert that to hex, and you get 0x23 (I'm using 0's for x). Thus, your array would look something like:
int led[10] = {..., 0x23, ...};

Then, to turn on LED 3, you would call:
outportb(0x378, led[3]);

Note that because of the active low outputs of the demuxer, and the fact that I don't have a schematic, you may need to invert b0-b2 to get the desired output.