Overview
- Object ID : 4911 (2024-11-05 19:49:10)
- Author : Michael
- Content : Code
- Microcontroller : Propeller 2
- Language : SPIN2
- Categories : Signals, Snippet
- Licence : MIT
Content
One method to check the pin state of an IO pin is to drive the pin in either direction (high/low) using the P2 smart-pin weak drive feature, and then test the signal level to determine if an external signal is pulling the IO pin in either direction.
The attached demo uses a method called "check_pinstate" and shows the result on the P2 Edge Module on-board LEDs
Tips:
- When using the P2-EC Edge module, make sure the LED dipswitch is turned on.
- If using the P2-EC32MB Edge module, adjust the code to use LED pins 38 & 39 (instead of 56 and 57)
- If using the P2-EVAL board, the LED state will be inverted!
This code was written with: Simple Tools IDE version 0.40.0