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

5
votes
1answer
247 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 ...
4
votes
5answers
658 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 ...
4
votes
3answers
214 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 ...
2
votes
1answer
152 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> ...
1
vote
1answer
194 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 ...
1
vote
1answer
239 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
107 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, ...
1
vote
1answer
131 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 ...
0
votes
1answer
56 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
86 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
55 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 ...
0
votes
1answer
255 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 ...
0
votes
1answer
97 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 ...
0
votes
1answer
27 views

Inheritance: error in calling the constructor of the base class?

I want to write a library for the RGBDigit shield (http://rgbdigit.com/), which essentially is an Adafruit Neopixel strip, packed as a 7 segment display. The shield also has a DS3231 clock and an IR ...
0
votes
2answers
31 views

Pass a member function pointer to a method of a foreign class (EDB Lib)

I'm currently working on my own arduino library and I'm becoming exasperated with the following problem: I want to store data with the extended database library ...
0
votes
1answer
131 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 ...