Use a High pin to bring a pin low

Hi

I have a capacitive touch sensor that brings its output pin HIGH when it's sensor is touched. My device requires a pin to be brought low (74HC165 shift register) in order to activate. Can anyone offer any advice on how I could bring a pin to ground with a HIGH pin input?

Any tips on where I should look for a solution would be helpful.

Thanks

You could put that output into the base of an npn transistor. Emitter to ground, collector to Vin through a pullup resistor, and take your output from the collector.

edit.... v2 of schematic, shows current limiting resistor into base, and pulldown from base to make sure the transistor is open when your sensor isn't high.

high in low out.png

high in low out v2.png

JimboZA:
You could put that output into the base of an NPN transistor.

You could, but you need to do it through a 10k (or 47k or 100k) resistor.

Alternatively you can use one gate in a CMOS inverter chip, such as a 74HC14, especially if you already have one, or a use for the other gates. Very useful for oscillators to flash LEDs and such or make noise. On the other hand, if your device was controlled by a microcontroller such as an Arduino, you would not need to invert the input as you would do that is software.

Paul__B:

JimboZA:
You could put that output into the base of an NPN transistor.

You could, but you need to do it through a 10k (or 47k or 100k) resistor.

Yep I had fixed that just before you posted....

Thanks Guys!

JimboZA I had an idea that a transistor may work but I did not know how to actually wire it up. Your diagram looks perfect. Thanks so much!

Paul__B:

JimboZA:
You could put that output into the base of an NPN transistor.

On the other hand, if your device was controlled by a microcontroller such as an Arduino, you would not need to invert the input as you would do that is software.

My board is a DIY Arduino. Are you saying that there is a way in software to make the 74hc165 look for high values rather than low?

The inverter chip looks interesting as well. I might even have one handy. I will have to investigate that.

Thanks again for your input.

Are you saying that there is a way in software to make the 74hc165 look for high values rather than low?

He more likely means that you could read the sensor on an Arduino pin and put its inverse out on another, and put the '165 on there.

freddyk:
JimboZA .... Your diagram looks perfect. Thanks so much!

Usual disclaimers apply.... YMMV, E&OE etc. 8)

Heed Paul__B on the size of R3

JimboZA:

Are you saying that there is a way in software to make the 74hc165 look for high values rather than low?

He more likely means that you could read the sensor on an Arduino pin and put its inverse out on another, and put the '165 on there.

Ok. I get that. I am trying to avoid using new pins. I had this nice elegant shift register setup to read buttons then I had to go and find this touch sensor...

freddyk:
Ok. I get that. I am trying to avoid using new pins. I had this nice elegant shift register setup to read buttons then I had to go and find this touch sensor...

I cannot figure out exactly what you are doing with the HC165 that requires you to invert the pin. If it is a data pin and you are shifting data into a microcontroller, then you perform the inversion in logic in the sketch after you have read the data into the microcontroller. If you want it to look right as a byte, you simply perform an XOR with whichever (number of) bits you need to swap.

JimboZA:
Heed Paul__B on the size of R3

However the resistor from the base to ground (R2) - if you use it - must also be no less than half the value of R3.

Thanks Paul__B

Sorry that my explanations are not so clear. I have figured enough of this stuff out to be dangerous but that does not mean I know what I am doing.

I am going to investigate if I can do this in logic. That would be really nice. Currently if I connect the output of the touch sensor to one of the input pins on the 74hc165 I can see that some power is coming from the 74hc165 so I assume it is high and waiting to be pulled low. So what you are saying is that I can use logic to make the default state of the 74hc165 pins low and wait for high?

If I can't figure that out I may go with the Schmidt Triggers that were mentioned earlier. I have some of those.

Thanks again for being so helpful.

freddyk:
I have figured enough of this stuff out to be dangerous but that does not mean I know what I am doing.

That may be the case!

freddyk:
I am going to investigate if I can do this in logic. That would be really nice. Currently if I connect the output of the touch sensor to one of the input pins on the 74hc165 I can see that some power is coming from the 74hc165 so I assume it is high and waiting to be pulled low. So what you are saying is that I can use logic to make the default state of the 74hc165 pins low and wait for high?

It begins to sound as if you have a serious misunderstanding of the situation, confusing "pull-ups" with logic states. A 74HC165 is a CMOS device with extremely high impedance inputs; there should be no "power coming from the 74hc165" at all; that is not the point.

I think you had better provide us with a diagram of your circuit and a web reference to the "touch sensor". Otherwise we have no idea what you are really trying to do and are clearly not talking on the same level.

Thanks Paul__B. Yea. Me and miss-understanding go way back.

I am going to try a few ideas based on your input.

In case you are curious this is the breakout I am using: Adafruit 12-Key Capacitive Touch Sensor Breakout - MPR121 [STEMMA QT] : ID 1982 : $7.95 : Adafruit Industries, Unique & fun DIY electronics and kits and I have attached my Eagle schematic. The board has already been built so I wan to work with as much of it as I can.

In my signature you can see pictures of the assembled board.

btnGame-V3.sch (907 KB)

and I have attached my Eagle schematic

Not everyone has Eagle: better probably to export as an image and post that.

JimboZA:
better probably to export as an image and post that.

Good idea. The area indicated in red is the focus. I have some terminal blocks that I have been used to connect switches. I want to connect the output from the touch breakout board.

OK, now the Adafruit touch sensor you cite requires an I2C interface, so you would need to connect it directly to the appropriate (and in fact, specific) pins on the Mega328 and include the necessary libraries to use it.

You may have imagined that you could use the "interrupt" output from the touch sensor breakout to indicate a touch. You cannot, as you must have the I2C interface in order to control the touch sensor to initialise it ("turn it on") and then when it does indicate a "touch" on the "interrupt" pin, you have to acknowledge the touch using the I2C interface or else the interrupt will simply stay permanently activated.

OK?

Well that is to bad. Thanks for your help.

freddyk:
breakout I am using: Adafruit 12-Key Capacitive Touch Sensor Breakout - MPR121 [STEMMA QT] : ID 1982 : Adafruit Industries, Unique & fun DIY electronics and kits

Duh! the link to the breakout board I posted was wron. this is the board I have:

I think this board has more straight forward outputs than the previously posted board.

I suspected that just might be the case.

OK, this should be no problem as unlike the other breakout, this one runs with 5V logic. The outputs are open-drain (same as "open-collector") so you need to pull them up to 5V Vcc with a 10k resistor. Other than that, they can be connected directly to your 74HC165 inputs.

In fact, as I recall from your board pattern, you already have the pullups on the board and nothing further need be done - just connect them :smiley:

Thanks Paul__B!

I will have to try that again. It would be amazing/lucky/fortunate if that was the case. I will let you know.