Go Down

Topic: How to use a hex inverter??? (Read 5728 times)previous topic - next topic

stinky

Dec 27, 2005, 11:35 pm
I'm trying to use a hex inverter to create a DPDT switch which can be controlled by a single pin on the arduino board.

Below is a bad drawing of my circuit (Please forgive me - I am an electronics newbie!)

A is connected to a pin on the arduino board.

The idea is that when ...

A is HIGH,     B is HIGH and C is LOW
and when ...
A is LOW,     B is LOW and C is HIGH

Anyway, its not working. I guess i'm doing this totally wrongly. Could somebody please put me right??

(merry christmas! to you all and I wish you a geeky 2006!)

DojoDave

#1
Jan 01, 2006, 12:28 pm
Hej,

sorry for the delay, we took a couple of days vacation visiting mum and eating Xmas candy ;-)

However your circuit looks great to me. I think you plugged everything right. The only thing I could ask is:

a) how big is your resistor?

b) can you take a picture of the circuit as you mounted it and upload it?

/David

stinky

#2
Jan 04, 2006, 05:00 amLast Edit: Jan 05, 2006, 12:50 am by stinky Reason: 1
hi David,

thanks for the help.

here is a picture of my circuit....

the long orange wire is the output, 'A' in my circuit diagram.

the two green wires are connected back onto the arduino board, for the purposes of testing. they are B & C

the resistor is 10Kohms

This is the 'quick and dirty' program I have on the arduino board to test the circuit...

------------------------------

int inA = 0;
int inB = 0;

void setup()
{
pinMode(11, OUTPUT);
pinMode(9, INPUT);
pinMode(8, INPUT);
beginSerial(9600);
}

void loop()
{
digitalWrite(11, HIGH);

printByte('h');
if (inA == 0) printByte('0');
else printByte('1');
printByte(' ');
if (inB == 0) printByte('0');
else printByte('1');
printByte(10);
printByte(13);

delay(1000);

digitalWrite(11, LOW);

inA = 0;
printByte('l');
if (inA == 0) printByte('0');
else printByte('1');
printByte(' ');
if (inB == 0) printByte('0');
else printByte('1');
printByte(10);
printByte(13);

delay(1000);
}

------------------------------

i get the following repeating output in ZTerm
`h   0   1l   0   0`

meaning that when A is High, B is High and C is Low
and when A is Low, B is Low and C is Low.

So, something is obviously wrong.

what does the digital doctor suggest??

DojoDave

#3
Jan 04, 2006, 10:35 pm
Hej,

take a look at your program:

Quote

delay(1000);

digitalWrite(11, LOW);

// THIS IS IT!!
// YOU ARE MAKING INA BECOME 0 AGAIN!!

inA = 0;

printByte('l');
if (inA == 0) printByte('0');
else printByte('1');
printByte(' ');
if (inB == 0) printByte('0');
else printByte('1');
printByte(10);
Saw it?

;-)

/David

stinky

#4
Jan 05, 2006, 12:42 am
whoops! how embarrassing!!!

yeah, i put that line in at one point, when I was trying to debug things and I forgot to remove it. without it, everything works as expected!

I put a scratch through that line, so that anybody looking at this thread can easily see what was wrong.

I hope the pictures will be useful to anyone else trying to do the same thing.

Thanks doctor - I'll try not to waste your time in future!!

#5
No waist,

a pleasure

/D

Go Up