5 years, 8 months ago.

USBKeyboard + Serial Output


im trying to use the USBKeyboard and a serial output at the same time. If I use just one of them everything works fine. As soon as I add the USBKeyboard to the code the serial output stops.

I tried using USBSerial to get the serial output from the normal USB port which works fine. But the keyboard on the SDA port still does not work.

Is it all possible to have the USBKeyboard and a serial output at the same time?

My Hardware:

  • Mac 10.10.3 Yosemite.
  • Board Name is: FRDM-KL25Z
  • MicroBoot Kernel Version is: 1.05
  • Bootloader Version is: 1.11
  • Installed Application: PEMicro FRDM-KL25Z Mass Storage/Debug App
  • Application Version is: 1.14

This is my code:

Trying to get serial and USBKeyboard working at the same time

#include "mbed.h"
#include "USBKeyboard.h"
#include "MMA8451Q.h"
#include <USBSerial.h>
#define MMA8451_I2C_ADDRESS (0x1d<<1)

DigitalIn finger1_up(PTD3);
//Serial serial(USBTX, USBRX);
USBSerial serial;

PinName const SDA = PTE25;
PinName const SCL = PTE24;
//USBKeyboard keyboard;

int main(void)
    MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS);
    while (1) {
        float x, y, z;
        x = abs(acc.getAccX());
        y = abs(acc.getAccY());
        z = abs(acc.getAccZ());
        serial.printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n", x, y, z);
Be the first to answer this question.