27 lines
1.2 KiB
Markdown
27 lines
1.2 KiB
Markdown
# crocodile clips
|
|
|
|
The on pin pressed accessories.
|
|
|
|
Register an [event handler](/microbit/reference/event-handler) that will execute whenever the user attaches one side of the crocodile clip to the `GND` pin, then connects and disconnects the unattached side of the crocodile clip to pin `0`, `1`, or `2`.
|
|
|
|
### Example: on pin pressed with random numbers
|
|
|
|
This example displays a random number every time the crocodile clip holds `GND` then connects and disconnects the `P0` pin. Each time the crocodile clip is firmly connected and disconnected from pin `P0`, the micro:bit will return a random Number between 0 and the parameter limit
|
|
|
|

|
|
|
|
### Connecting Crocodile Clips
|
|
|
|

|
|
|
|

|
|
|
|
### Lessons
|
|
|
|
[love meter](/microbit/lessons/love-meter)
|
|
|
|
### See also
|
|
|
|
[micro:bit pins](/microbit/device/pins), [pin is pressed](/microbit/reference/input/pin-is-pressed), [analog read pin](/microbit/reference/pins/analog-read-pin), [analog write pin](/microbit/reference/pins/analog-write-pin), [digital read pin](/microbit/reference/pins/digital-read-pin), [digital write pin](/microbit/reference/pins/digital-write-pin)
|
|
|