Welche Pins sind denn mit Pull-Up Widerständen beschaltet.
Ich möchte für das GameZIP Events über pinonpulsed ausgelöst bekommen mithilfe von setpull usw. Das funktioniert auch bei P0,P1,P2 wunderbar, mit den anderen Pins aber irgendwie nicht.
meine Custom.ts:
// % weight=0 color=#0fbc11 icon="\uf11b"
// block=“GameZIP”
namespace gameZIPjoystick {
export enum JoystickBitPin {
//% block="Left"
P12 = 13, //C12
//% block="Right"
P13 = 11, //C5
//% block="Down"
P14 = DigitalPin.C6,
//% block="Up"
P8 = DigitalPin.C4,
//% block="Fire1"
P15 = DigitalPin.P0,
//% block="Fire2"
P16 = DigitalPin.P3
}
export enum ButtonType {
//% block="gedrückt"
down = PulseValue.High,
//% block="losgelassen"
up = PulseValue.Low
}
/**
* initialization joystick:bit
*/
//% blockId=initJoystick block="Initialisiere Joystick"
export function initJoystick(): void {
pins.setPull(13, PinPullMode.PullUp)
pins.setPull(DigitalPin.C4, PinPullMode.PullUp)
pins.setPull(11, PinPullMode.PullUp)
pins.setPull(DigitalPin.C6, PinPullMode.PullUp)
pins.setPull(DigitalPin.P0, PinPullMode.PullUp)
pins.setPull(DigitalPin.P3, PinPullMode.PullUp)
}
/**
* get Button
*/
//% blockId=getButton block="button %button is pressed"
export function getButton(button: JoystickBitPin): boolean {
return (pins.digitalReadPin(<number>button) == 0 ? true : false)
}
/**
* Registers code to run when a joystick:bit event is detected.
*/
//% blockId=onButtonEvent block="Wenn Knopf %button | %event|" blockExternalInputs=false
export function onButtonEvent(button: JoystickBitPin, event: ButtonType, handler: Action): void {
pins.onPulsed(<number>button, <number>event, handler);
}
/**
* vibration motor
* @param time describe parameter here, eg: 100
*/
//% blockId=Vibration_Motor block="motor vibrate for %time ms"
export function Vibration_Motor(time: number): void {
pins.digitalWritePin(DigitalPin.C17, 0)
basic.pause(time)
pins.digitalWritePin(DigitalPin.C17, 1)
}
}
Im Hauptprogramm ist natürlich die LED-Matrix ausgeschaltet:
led.enable(false)
Ideen oder Infos?