I am a beginner at programming with Arduino and I am unsure on how can I call functions (such as, getData()) for the touchscreen LCD to display that data. The purpose of my device would be to listen to data communications between sensors and a controller and thus I have one RedBoard with CAN-BUS shield with a dataComms.ino sketch, which initialises getting data functions from received data packets and parses them.

Do I need to create another sketch for the display? If so, how can I call functions from another sketch, so that display.ino would have access to received values? Or are there some better ways of displaying data?

closed as unclear what you're asking by per1234, sempaiscuba, VE7JRO, gre_gor, Dmitry Grigoryev Aug 2 '18 at 8:59

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


You can only use one sketch at a time, meaning one sketch can be stored inside an Arduino to be executed.

This means all your code (and functionality for all devices you want to access) needs to be within that single sketch.

So what you mostly need to do is:

  • Add a library for every device that you want to use.
  • Call functions from that library in your .ino file.
  • If you want to add functions which are not part of a library, you add both the function code and the call (where you need it) in your .ino file.

Also if you are new, don't start with everything at the same time.

  • First find an example how to control the display (that's probably easier than the CAN shield).
  • Add the library for the display
  • Change (or copy from an example) code for the display
  • Run and debug it until it works.
  • Create a new sketch for the CAN shield.
  • Add the library for the CAN shield.
  • Call functions from that library (or use an example if available).
  • Once you are convinced you know how to use both devices (display + CAN), combine the sketches (create a new sketch, add both libraries, copy code and make it one sketch).
  • Thanks a TON! Does it mean that my .ino file acts as a main, through which I need to setup CAN Shield and LCD? Also, I suppose I will need to create .cpp and .h files to create libraries for both of the devices as well, won't I? (For prototypes and variable declarations) – Henrikas Matusevičius Jul 27 '18 at 14:28
  • I hope you already have the libraries (or they are existing).. Creating a library for a beginner is far from easy. The Arduino IDE has a mechanism already to add libraries (Manage/Add libraries or something, I don't have the IDE at hand). Your .ino file has two functions: setup (initializing) and loop (run continously). Main is hidden in the framework that Arduino IDE generates and it calls the setup and loop. Check for some basic examples. – Michel Keijzers Jul 27 '18 at 14:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.