How to invert the signal from a digital input pin in software?

I'm playing around with Ken Shirriff's IR library and it appears that my IR sensor is spitting out an inverted signal compared to what I need(on-off ratio seems to be backwards when looking at the data from the irdump example). So I'm trying to figure out how to invert the signal. Since I'm not clear on how the library uses other libraries I'm not sure where to do this operation. Simply putting a ! in front of the pin number obviously doesn't work. I tried creating another variable and setting it to the invert of the pin but I think this needs to sit in the loop where the pin is actually being read and not in main irdump sketch. Anyone understand where I'm going with this?

How is the sensor wired up to the pin?

Output is a neg logic feeding straight into the pin which is what Ken defines in his projects so it should be right. I have a pullup resistor enabled in the arduino because this IR detector doesn't have one internally. Meter shows the output is high (4.8v) until a signal comes through. But none of the IR signals I send are being decoded; they all show up as unidentified raw. So I decided to compare what I'm sending with what it should look like. Sending a sony code I looked at the result in the IR dump. The timing of spaces to marks seem like it might be backward from the Sony protocol listed at sbprojects.com.

Is your sensor a 2 pin or 3 pin device and do you have a make/model number for it. Normally the 3 pin variety don’t need pull-up resistors and the 2 pin version can have it’s logic state altered by where you place an external pull-up resistor in the circuit.

Why not use something like:

pin_state = !digitalRead(pin_number);

I guess I don't understand the confusion.

2 Likes