Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let IR2 = 0
- let index = 0
- let A: number[] = []
- let Flag = 0
- let value = 0
- pins.onPulsed(DigitalPin.P0, PulseValue.Low, () => {
- if (pins.pulseDuration() > 2000) {
- Flag = 1
- }
- if (A.length <= 14 && Flag == 1) {
- A.push(pins.pulseDuration())
- }
- if (A.length == 14) {
- serial.writeValue("Length", A.length)
- index = 0
- IR2 = 0
- for (let value2 of A) {
- if (value2 > 1000) {
- IR2 = IR2 + 2 ** index
- } else {
- IR2 = IR2 + 0
- }
- index += 1
- }
- serial.writeValue("IR", IR2)
- A = []
- Flag = 0
- }
- })
- value = 0
- pins.setPull(DigitalPin.P0, PinPullMode.PullUp)
- A = []
- serial.redirectToUSB()
Advertisement
Add Comment
Please, Sign In to add comment