VS Arduino
>> >> Serial doesn't work in added empty c and h file
https://www.visualmicro.com/forums/YaBB.pl?num=1572210106

Message started by andi0000085 on Oct 27th, 2019 at 9:01pm

Title: Serial doesn't work in added empty c and h file
Post by andi0000085 on Oct 27th, 2019 at 9:01pm
Hi, I want to split up the functionality in several files. So I added an "empty arduino c and h file" and added a simple Serial.println command in a function. This function I will call in the main.ino file and I always get the error "SerialUSB" undeclared. What do I have to include to get the Serial working?

Thanks

Error:

Code (c++):

test.c: In function printTest

variant.h: 204:37: error: 'SerialUSB' undeclared (first use in this function); did you mean 'SerialGSM'?
   #define Serial                      SerialUSB
test.c:9: note  in expansion of macro Serial
   Serial.println("Hello3")


Title: Re: Serial doesn't work in added empty c and h file
Post by Visual Micro on Oct 28th, 2019 at 11:30am
use .cpp and .h not .c and .h. Ensure you add the #include "Arduino.h" to the code

VS Arduino » Powered by YaBB 2.6.12!
YaBB Forum Software © 2000-2024. All Rights Reserved.