Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: How to use USB serial? usb_init() not defined

  1. #1

    How to use USB serial? usb_init() not defined

    I did:
    #include <usb_serial.h>

    RSGPIO: In function 'void setup()':
    HRSGPIO:138: error: 'usb_init' was not declared in this scope
    usb_init();
    ^
    HRSGPIO: In function 'void loop()':
    HRSGPIO:204: warning: comparison between signed and unsigned integer expressions
    if (usb_serial_available() >= sizeof(controlPacket)) {
    ^
    'usb_configured' was not declared in this scope


    I expected those functions to be defined.

    Also I could not find any example code?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,805
    Quote Originally Posted by JasonH View Post
    Also I could not find any example code?
    In Arduino, click File > Examples > 04.Communication > ASCIITable.

    Or just do something simple like this to print to the serial monitor

    Code:
    void setup() {
    }
    
    void loop() {
      static int count = 0;
      Serial.print("Hello World ");
      Serial.println(count++);
      delay(100);
    }
    No need to include special headers or worry about low level USB details.

    Documentation can be found here:

    https://www.pjrc.com/teensy/td_serial.html

  3. #3
    Haha too easy!

    Thanks :facepalm:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •