Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [struct]

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

1
vote
2answers
32 views

Creating an array of structures which store bitmaps to work with u8glib

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 ...
0
votes
0answers
21 views

Parsing multiple jsonObjects with Arduinojson and return a list of values

I am building a table tennis score board which parses json objects with ID and names of players to let the players pick their name inside a menu and later on submit the scores to my server. But I am ...
0
votes
1answer
30 views

Message Interpreter and Handler - How to store a function name in a struct?

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 {...
0
votes
1answer
1k views

Printing char array from array of structs in progmem to serial

(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 ...
0
votes
1answer
33 views

Constants within array of structs causes strange compiler errors?

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 ...
0
votes
1answer
129 views

FastLED + structs + PROGMEM strange behavior

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 ...
1
vote
2answers
466 views

Function, struct or class?

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 ...
0
votes
0answers
32 views

Analog Read gives Erratic behaviour in Struct

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 ...
0
votes
1answer
1k views

Transfer serial data to struct variable in Arduino

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 *...
0
votes
1answer
86 views

Unexpected results and hard crash when modifying and addressing arrays & variables within a struct

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 ...
0
votes
1answer
186 views

MIDIUSB - Why is the command put twice?

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 { ...
1
vote
1answer
54 views

Can you pass the entries of a strut array to a int array? if so how?

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, ...
0
votes
1answer
1k views

Help with struct variable

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},...
1
vote
0answers
44 views

Erratic behavior from 'randomly' generated values in array

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 ...
0
votes
2answers
3k views

Use of struct and sizeof in C for Arduino

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 ...
1
vote
1answer
1k views

Casting a struct member between uint8_t and char, with regard to serial transfer

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((...
1
vote
3answers
3k views

Transfer a struct's data to an external struct via serial?

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 ...
3
votes
1answer
302 views

sending ctrl-z in a struct?

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.) ...
0
votes
1answer
813 views

I2C_Anything String / Char Array issues

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 ...
0
votes
2answers
3k views

Assigning value inside structure array outside setup and loop functions

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. ...
2
votes
2answers
7k views

Using PROGMEM to store array of structs

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 ...
2
votes
1answer
305 views

XBee, external libraries and passing structures as arguments

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 ...
9
votes
5answers
29k 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 ...
5
votes
1answer
391 views

Last element of a struct disappearing on write/read

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 { ...