A custom structure in C++ (and various other languages) which can contain member data and functions. An instance of a class is called an object.

learn more… | top users | synonyms

4
votes
3answers
169 views

Classes and objects: how many and which file types I actually need to use them?

I have no previous experience with C++ or C, but know how to program C# and am learning Arduino. I just want to organize my sketches and am quite comfortable with the Arduino language even with its ...
0
votes
1answer
78 views

Can't use base class and derived class functions

I have made two libraries and one test program.I have made my custom uart library.first i have included all functions for printing in single uart library file.but then i have made print library for ...
2
votes
1answer
110 views

Custom Arduino library problem

I have made my custom serial(UART) library. So I made uart.h and uart.cpp files as following. uart.h #ifndef UART_H #define UART_H #include <avr/io.h> #include <stdlib.h> ...
0
votes
1answer
40 views

Call a class method from inside the same class

If i have file cSpeedOfSound.h: #ifndef cSpeedOfSound_h #define cSpeedOfSound_h #include "Arduino.h" #include "math.h" class cSpeedOfSound{ public: cSpeedOfSound(float *i,float *C); ...
0
votes
2answers
58 views

Arduino raise the error: `does not name a type` when an Object is used outside of the main two blocks setup and loop

I have this: class Person{ public: int age; }; Person p; p.age; void setup() { ... } void loop() { ... } And I got this error: Compiling 'MyProgram' for 'Arduino Mega w/ ATmega2560 (Mega ...
0
votes
1answer
52 views

How to dynamically switch between between 2 objects?

I have a 40x4 LCD which internally consists of 2 40x2 LCDs. To control this LCD I have to create 2 LiquidCrystal objects and than later on in code decide which one to use depending on which of the 4 ...
1
vote
1answer
141 views

Use object of other class within class

I am writing a class for a project which will take care of handling any LCD updates for my project. The way I want to handle this is to initialize the LCD object in my main file, and then pass the LCD ...
0
votes
0answers
98 views

Variables not initialized in Class Constructor

I'm creating a library driver for AdaFruit's GFX library. During Constructor initialization, all the variables (set in another .cpp) are returned as zero. This code has several modular files to ...
1
vote
1answer
204 views

error: 'CLASS' does not name a type only when creating object inside another object

I'm trying to use Adafruit's LED Backpack library within a custom class. When I use the Adafruit library directly within a sketch, it compiles fine. When I use an example sketch provided with the ...
1
vote
2answers
99 views

How to prepare data structures and classes?

How can I port these structures to arduino ide, I also get error when I define pointers // pointer to classes example #include <iostream> using namespace std; class Rectangle { int width, ...
0
votes
1answer
233 views

Calling a function that is outside of a class from inside

I have an Arduino sketch with a timer interrupt class and would like to place the TIMER2Services() function in the TimerTwoTest.ino file for easy access. On compile I get a multiple definition of tmb2 ...
5
votes
1answer
230 views

Arduino Servo won't move when using classes

I'm trying to make a class work with Arduino, however it doesn't seem to trigger properly. The code is compiling perfectly, and it's supposed to control the leg of an hexapod. Also, the example sweep ...
1
vote
1answer
124 views

Initialize a “Matrix” object in my own library?

So, I'm trying to make a custom library to drive a 8x8 Bi-Color LED Matrix from 2 MAX7219's that incorporates two "Matrix" objects from the "Matrix" library and I cannot, for the life of me, figure ...
4
votes
5answers
626 views

What overheads and other considerations are there when using a struct vs a class?

C on embedded systems has traditionally use structs to hold structured data. Arduino brings C++ to the table, so we can use classes instead. Lets say we have two different data structures which ...