Skip to main content

Questions tagged [struct]

Refers to a basic data structure (also called record).

Filter by
Sorted by
Tagged with
0 votes
1 answer
130 views

I want to serialise and deserialise a struct containing a flexible array. I did find a working code but wondering if it is the most elegant and optimum way to do it. This is my first attempt below ...
Noel's user avatar
  • 163
1 vote
1 answer
231 views

I need to interface an ATTiny88 MCU configured as an I²C slave with a Raspberry Pi configured as an I²C master. I may be using the wrong approach, but I have a structure consisting of four different ...
LesRhorer's user avatar
  • 113
-1 votes
1 answer
40 views

i'm trying to create a program that given a configuration (i've used multiple struct nested) i need in loop() to check for each output if they need to be on or off and set the output accordingly let ...
Darkmagister's user avatar
0 votes
1 answer
264 views

For a RF project I need to split payload for a max predefined chunk size. For that I created a RFmsg struct. The unexplained part I need help in is why when I create a local instance of RFmsg, its ...
guyd's user avatar
  • 1,049
0 votes
0 answers
57 views

I've come across an interesting yet old article within StackExchange which has great examples of sending structured variables over serial communications. The library StreamSend.h and it's source code ...
Brian's user avatar
  • 11
9 votes
5 answers
2k views

I'm trying to transfer data between a Arduino Uno board to a NodeMCU ESP8266 board, using nRF24L01+ transceivers module and RF24 library on both side. The data I'm transferring are stored in a struct ...
Vincent's user avatar
  • 232
1 vote
1 answer
524 views

The goal for this is to create a struct that includes a name, ID, fileName, and a boolean, then create an array of that structs. Here's what I came up with: struct Amiibo { char *aName{}; char *ID{...
Ethan Braun's user avatar
1 vote
1 answer
77 views

I am currently trying to determine how the ESP8266 WifiSniffer program by Kalanda works. Here is the source code: #include <Arduino.h> extern "C" { #include <user_interface.h> ...
Lachlan Etherton's user avatar
1 vote
0 answers
1k views

I am trying to create a class and getting getting the error incompatible types in assignment of 'const String' to 'char [32] when I declare char inString[32]; and try to set it as inString = server....
brad's user avatar
  • 201
4 votes
2 answers
19k views

I defined myself a struct: typedef struct { unsigned char current; unsigned char start; unsigned char target; unsigned long startTime; unsigned int duration; } led; I was able to initialize ...
iGEL's user avatar
  • 143
2 votes
2 answers
2k views

I need to initialize several buttons and LEDs connected to my Arduino. To store data related to an individual button or LED, I decided to define my own data type using two different structs. One for a ...
albert's user avatar
  • 205
3 votes
3 answers
7k views

I'm trying to make a use of a relay module, I want a clear way to configure and control my relay module I've defined the struct and filled it with some info about id, pin number, title, and relay ...
Moktar's user avatar
  • 31
1 vote
2 answers
459 views

I have 2 instances of a struct. One has def values stored and second stores values read from a file on SPIFFS. I'm trying to use a for loop over all struct's variables - if file was read OK and key ...
guyd's user avatar
  • 1,049
0 votes
1 answer
514 views

So i have struct: typedef struct sendPacketStruct { byte header = headerByte;//0x55 unsigned int time;//2 bytes int height;//2 bytes }; And i do this: sendPacketStruct sendPacket; ...
Hayden Thring's user avatar
3 votes
0 answers
23 views

This is my first question! i'm sorry if i'm doing something wrong. I'm trying to write a code that blinks some leds, but i cant quite work out how to use structs as arguments. This is the code: void ...
Dariem Fabián Hidalgo Arias's user avatar
1 vote
2 answers
5k views

I made this simple code but I'm getting the following error exit status 1 'RGB' does not name a type typedef struct RGB { double r; double g; double b; }; RGB led; RGB func()...
Ivan Taccadoli's user avatar
2 votes
2 answers
11k views

Suppose that one defined a data structure and wanted to send it through serial. struct Gyro_data_structure { char command_name[5]; float gyro_X; float gyro_Y; float gyro_Z; }; ...
ShoutOutAndCalculate's user avatar
0 votes
1 answer
93 views

TL;DR: I tried to have a random fading pattern on several leds and it leads to flickering. Edited following @chrisl answer. I am in the process of creating a simple lamp that show some light ...
Guillaume_slize's user avatar
0 votes
1 answer
572 views

I got the below code generated this amazing tool. const size_t capacity = JSON_ARRAY_SIZE(2) + JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(4) + 2*JSON_OBJECT_SIZE(7); DynamicJsonDocument doc(capacity); ...
Anum Sheraz's user avatar
1 vote
2 answers
1k views

Basically I'm trying to output a string based upon a value in an array, the following code is what I have come up with to achieve my desired result, but I have a feeling that there is a better way to ...
H3xx1st's user avatar
  • 11
-1 votes
2 answers
187 views

I am working on a project where I have to build an IR program that works with all of the AVR/Arduino boards to control the IR devices such as TV, DVD, etc. I am building a struct that can carry the ...
Alex Zhuravel's user avatar
2 votes
2 answers
2k views

This sketch does not compile in the Arduino IDE void setup() { // put your setup code here, to run once: } struct test { int i; char variable[]; }; typedef struct test test; test t = { 0, ...
the_architect's user avatar
0 votes
2 answers
97 views

I haven't needed classes before in programming for Arduino, but I now have a good use case. I'm not sure I grasp how this will affect code space, though. Currently I have a struct that holds the ...
Jim Mack's user avatar
  • 269
1 vote
2 answers
879 views

I've tried reading the documentations and I'm getting desperate because I can't find anything. I need to create an array of structures, which contains a bitmap stored in PROGMEM space (because of ...
OM222O's user avatar
  • 199
0 votes
1 answer
95 views

For a project, I need to store an array of structures in PROGMEM. Array MessageTable[] will be composed of about ten struct InMessage elements. InMessage looks sort of like this: struct AvcInMessage {...
Bo Thompson's user avatar
0 votes
1 answer
3k views

(I apologize if this is a c++ question, I'm too green to know if this is unique to the Arduino IDE) I've moved an array of structs into my PROGMEM because I was running into memory issues: #define ...
Bo Thompson's user avatar
0 votes
1 answer
61 views

In my sketch I have the following: #define HU_ADDR 0x190; #define ALL_AUDIO_ADDR 0x1FF; #define MY_ADDR 0x360; #define UNKNOWN_ADDR 0xFFF; typedef ...
Bo Thompson's user avatar
0 votes
1 answer
492 views

I'm afraid I have to post a lengthy bit of code, because I can't pinpoint what's causing my issues – in short, it appears repeatedly adding float position + float speed in a struct ends up borking the ...
Bogdan Stăncescu's user avatar
1 vote
2 answers
1k views

I am trying to learn more about arduino programming, and recently i've written functions for randomizing and then modifying a single array. Now i'd like to do the same for four individual arrays. This ...
Erik's user avatar
  • 271
1 vote
0 answers
75 views

I'm getting some very strange behaviour from a Haptic feedback system I'm trying to make. The test code works fine as a Multiple-In One-Out in the main loop, but once I moved the code to the Struct, I ...
Minothor's user avatar
  • 111
0 votes
1 answer
3k views

I have declared a struct with some variables that right now are fixed, but one of the variables on the struct needs to be what the Arduino's serial port reads. struct testing_var { const char *...
Luz A's user avatar
  • 69
0 votes
1 answer
249 views

I'm trying to use a 2D array inside a struct on my arduino to store sensor readings. I'm having two main problems: 1: My Arduino is crashing and resetting when I try to access certain directories in ...
Gtingstad's user avatar
0 votes
1 answer
891 views

Consider this function: void noteOn(uint8_t pitch) { midiEventPacket_t noteOn = {0x09, 0x90 | 9, pitch, 127}; MidiUSB.sendMIDI(noteOn); } midiEventPacket_t is defined as: typedef struct { ...
Jonathan S. Fisher's user avatar
1 vote
1 answer
134 views

typedef struct { uint8_t pitch; }LearnNote; #define MAX_NOTE 500 LearnNote Noteseq[MAX_NOTE]; int learnindex=0; void loop() { MIDI.read(); } void MyHandleNoteOn(byte channel, byte pitch, ...
Hjhk90's user avatar
  • 291
1 vote
1 answer
6k views

I made a struct like this: typedef struct { int color[3]; int positions[4]; char init[20]; void (*fn)(); } buttons; and a variable like this: button test[1] = { {{0,0,0},{0,0,100,100},"...
onlygio's user avatar
  • 13
2 votes
0 answers
72 views

Currently working on a data collection algorithm on the Arduino MEGA (ATMega1280) and I've run into a problem with some of the code I've written. I feel my problems may be stemming from the way in ...
Justin Shetty's user avatar
1 vote
2 answers
5k views

I am a newbie in C and I can not understand the point of using a structure in C. Could someone explain to me what is the point of defining a structure in C programming? For example, this code(written ...
Jack's user avatar
  • 143
1 vote
1 answer
3k views

Im simply trying to pass my payload to another device that has the same architecture and struct. I'm using UART to transfer, and modeling the protocol from EasyTransfer. When I call Serial.print((char*...
Womble's user avatar
  • 199
2 votes
4 answers
10k views

Using two boards of similar architecture I would like to send the contents of a struct from the sending board to the receiving board. I am using UART to transfer. My plan was to populate an array ...
Womble's user avatar
  • 199
3 votes
1 answer
929 views

I have a set of buttons wired to an arduino leonardo that are meant to send either single keystrokes to a computer "a, b, c..." etc, or a key sequence like ctrl+z (to perform an undo command.) ...
sylcat's user avatar
  • 65
0 votes
1 answer
2k views

I've been working with the lovely I2C_Anything.h (thanks to the great work and support from Nick over at http://www.gammon.com.au/forum/?id=10896&reply=9#reply9).. All working great, I was using ...
Andology's user avatar
0 votes
2 answers
4k views

I'm having some difficulty assigning a value to a variable in a struct array outside the loop and setup functions. Assigning a value to an int or char array works completely fine but this doesn't. ...
oduffy's user avatar
  • 79
5 votes
2 answers
12k views

I am hitting the limits of my arduino's SRAM and found that SRAM usage can be reduced by storing static stuff in flash memory instead of SRAM. My project can (optionally) be built with an included ...
Alex's user avatar
  • 181
2 votes
1 answer
436 views

I have very weird problem with a library I am creating. The library will be used to communicate between Arduino modules using XBee Series 1 modules. Library is very simple wrapper library around ...
MichalG's user avatar
  • 121
22 votes
5 answers
79k views

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 ...
Cybergibbons's user avatar
  • 5,430
5 votes
1 answer
526 views

I'm building a weather station with two UNOs, using NRF24l01+ radios. Communications are fine. I'm sending a struct from one to the other. The struct has three elements: struct weather { ...
brorobw's user avatar
  • 71