You need hardware that is compatible, voltage-wise, with the Arduino. Smoke happens if you feed 12V into the Arduino.
Until you have useful hardware, the sketch is pointless.
Without knowing how you have connected the hardware, no one could write a sketch for you. That is not what we do here, anyway. What we do here is help you write a sketch. Reading from, and writing to, digital pins is extremely simple.
Power connected to the barrel jack must be between 7 and 12 volts, connect signal wire to a digital pin, pin 2 would work. Have you tried to write any kind of sketch? If so, please post it, we can go from there.