-1

I have the following code for Micro:Bit:

void onButtonA(MicroBitEvent e)
{
    int x = uBit.accelerometer.getX();
    int y = uBit.accelerometer.getY();
    int z = uBit.accelerometer.getZ();
    uBit.display.print("A");
    uBit.serial.printf("Button: A \r\n x:%i y:%i z:%i \r\n",x,y,z);
}

void onButtonB(MicroBitEvent e)
{
    int x = uBit.accelerometer.getX();
    int y = uBit.accelerometer.getY();
    int z = uBit.accelerometer.getZ();
    uBit.display.print("B");
    uBit.serial.send(""Button: B \r\n x:%i y:%i z:%i \r\n",x,y,z");
}

int main()
{

    uBit.messageBus.listen(MICROBIT_ID_BUTTON_A, MICROBIT_BUTTON_EVT_CLICK, onButtonA);
    uBit.messageBus.listen(MICROBIT_ID_BUTTON_B, MICROBIT_BUTTON_EVT_CLICK, onButtonB);

    uBit.display.print("S");
    uBit.serial.send("Starting Micro:Bit Program \r\n");

    release_fiber();
}

This is supposed to write at serial.

On my macbook I check for the usb serial ls /dev/tty.* with the following result:

/dev/tty.usbmodem1422

So I try the following:

screen /dev/tty.usbmodem1422

Then I press some buttons from micro:bit but nothings appears on terminal. What I'm missing?

Lechucico
  • 1,914
  • 7
  • 27
  • 60

1 Answers1

0

There was everything correct. The only think I was missing is the baud (https://www.microbit.co.uk/td/serial-library). With the following correction on the screen command it works perfectly:

sudo screen /dev/tty.usbmodem1422 115200

enter image description here

Lechucico
  • 1,914
  • 7
  • 27
  • 60