edison-js / Edison

💡Edison can controll microcomputer with TypeScript and React💡
https://edison-js-document.vercel.app/
MIT License
45 stars 6 forks source link

Error on input sensor #63

Closed yoshihikko-kodaira closed 5 months ago

yoshihikko-kodaira commented 5 months ago

The infrared sensor is working properly, but the program is not returning the correct value.

import { SerialPort, attachHallEffectSensor, attachLed, board } from "edison";

board.connectManual("/dev/ttyUSB0");

board.on("ready", (port: SerialPort) => {
  console.log("Board is ready!");
  const led1 = attachLed(port, 13);

  const infraredObstacleAvoidanceSensor = attachHallEffectSensor(port, 3);
  infraredObstacleAvoidanceSensor.read("on", () => {
    led1.on();
    console.log(1);
  });
  infraredObstacleAvoidanceSensor.read("off", () => {
    led1.off();
    console.log(0);
  });
});

In the above code, when the sensor is on, the value 0 may be output.

AllenShintani commented 5 months ago

Thank you so much your report of bug!! I reviced this bug and I 'll push PR here!