How to use a hex inverter???

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!)

Hej,

sorry for the delay, we took a couple of days vacation visiting mum and eating Xmas candy :wink:

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

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);

inA = digitalRead(8);
inB = digitalRead(9);
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 = digitalRead(8);
inB = digitalRead(9);
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   1
l   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??

Hej,

take a look at your program:

delay(1000);

digitalWrite(11, LOW);

inA = digitalRead(8);
inB = digitalRead(9);

// 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?

:wink:

/David

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!!

No waist,

a pleasure

/D