MakeCode package for touch sensing with the capacitive touch sensor controller MPR121.
The MakerBit connects to the BBC micro:bit to provide easy connections to a wide variety of sensors, actuators and other components. Among other things, it features a MPR121 controller.
MakerBit | MakerBit+R with motor controller |
MakerBit offers built-in support for up to 12 touch sensors via the proximity capacitive touch sensor controller MPR121.
Do something when a touch sensor is touched or released.
makerbit.onTouch(TouchSensor.T5, TouchAction.Pressed, () => {})
sensor
- the touch sensor to be checkedaction
- the trigger actionhandler
- body code to run when the event is raised
Returns the sensor index of the last touch event that was received. It could be either a sensor touched or released event.
makerbit.touchSensor()
Returns true if a specific touch sensor is currently touched. False otherwise.
makerbit.isTouched(TouchSensor.T5)
sensor
- the touch sensor to be checked
Returns true if any sensor was touched since the last call of this function. False otherwise.
makerbit.wasTouched()
Licensed under the MIT License (MIT). See LICENSE file for more details.
- for PXT/microbit
- for PXT/calliope