Connect the crocodile plugs to the ``GND`` and ``P0`` pins on the micro:bit.
![](/static/mb/projects/timing-gates/connectcrocs.jpg "Connecting the micro:bit")
The gate is ready to use! Your circuit should look like the picture below:
![](/static/mb/projects/timing-gates/sensordone.jpg "A single gate")
## Detecting the car with code
The micro:bit provides an event [on pin pressed](/reference/pins/on-pin-pressed)
that is raised when a circuit between ``GND`` and a pin is detected. The circuit conductor could be a wire or even your body!
We will attach a foil to the bottom of the car. When it passes over the gate, it connect both foil strips, close the circuit and trigger the event.
Open the [code editor](/) and start a new project and add the following blocks. Notice that we are using pin ``P0`` here.
```blocks
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
input.onPinPressed(TouchPin.P0, () => {
basic.showLeds(`
# . . . .
# . . . .
# . . . .
# . . . .
# . . . .
`)
})
```
Testing the code with our finger, we see a LED column turn on when pressing both strips.
https://youtu.be/zi_-NAmdDpY
## Upgrading the car
In this lesson, we picked a random toy car and tapped foil to the bottom.
As the car goes through the gate, it will connect both sides of the gate and trigger it. Make sure to add enough foil to get a good connection on the ground.
![](/static/mb/projects/timing-gates/carfoil.jpg "Attaching foil to the car")
By moving the car (slowly) through the gate, you will see that it triggers the ``on pin pressed`` event.
https://youtu.be/M3DIUvDPlIA
### ~hint
It does not work always! Sometimes the foil does not touch long enough both strip to be detected. This is due to the poor quality of our sensor.
To fix this, you would have to consider using better sensors based on IR or Hall effect.
### ~
## Adding the second gate
Repeat the same process with tape and foil to build the first gate.