Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a "Hello World" via Serial example #24

Open
adamvoss opened this issue Aug 31, 2017 · 1 comment
Open

Need a "Hello World" via Serial example #24

adamvoss opened this issue Aug 31, 2017 · 1 comment

Comments

@adamvoss
Copy link
Contributor

Just needed to do some "shotgun debugging" and realized I wasn't sure how to do that with Arduino (Morse on an LED? :-P ), normally the Hello World program provides the needed pieces to be able to do that.

I think adding a more conventional "Hello World" using SerialUSB would address this.

@IanBoyanZhang
Copy link

Hi @adamvoss,

Hopefully, this is what you are looking for or more practical with CAN reading?

void setup() {
  // put your setup code here, to run once:
  SerialUSB.begin(0);
  pinMode(DS2, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  while (!SerialUSB.available()) {
    return;  
  }
  serialUSBEvent();
  // USB serial can be really fast, mb/s.
  delay(500);
}

void serialUSBEvent() {
  String str = "Hello Word!\n";
  SerialUSB.write(str.c_str())  ;
}

I tried this quickly with screen /dev/xxx.yourusbport on OS X. For some reason, I have to send a key press to trigger usb event. After that the communication is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants