PDA

View Full Version : another question...



nathan
02-25-2005, 04:13 AM
ok.. the tutorial doesn't really explain how to set multiple pins to high and low... so lets say for example i expand it to 2 leds... i have pin 2, and 3 hooked up to led's... how could i set them individually to low, and high? (in c using _outb)

vikas
02-25-2005, 04:28 PM
Its simple

_outp passes 8 bits which correspond to 8 leds :) in you language .

so 00000001 is 1st led
and 00000010 is 2nd led

to change the state of either similarly OR or AND the current state with the appropiate number and pass the number to the port .

To turn 2nd on simply OR with 2 which is

00000000 OR 00000010 = 00000010 ( previous state off )
00000010 OR 00000010 = 00000010 ( previous state on )

To switch off

00000000 AND 11111101 = 00000000 ( previous state off )
00000010 AND 11111101 = 00000000 ( previous state on )

Nurse
12-18-2016, 09:26 PM
Its simple

_outp passes 8 bits which correspond to 8 leds :) in you language .

so 00000001 is 1st led
and 00000010 is 2nd led

to change the state of either similarly OR or AND the current state with the appropiate number and pass the number to the port .

To turn 2nd on simply OR with 2 which is

00000000 OR 00000010 = 00000010 ( previous state off )
00000010 OR 00000010 = 00000010 ( previous state on )

To switch off

00000000 AND 11111101 = 00000000 ( previous state off )
00000010 AND 11111101 = 00000000 ( previous state on )

can you please be more specific? I don't seem to understand.