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 [c]

C is a procedural programming language which is widely used in embedded systems. PLEASE NOTE: Arduino is typically programmed in C++, not C.

2
votes
2answers
114 views

Using an external header file

I have a project that is part of a larger repository, and shares header files with non-Arduino C programs. I know that it's possible to use these headers by copying them to the libraries folder, or ...
0
votes
7answers
661 views

How to parse 20180810T143000Z to time_t

What is the shortest/most elegant way (i.e. use existing lib functions) to parse a string in the form of 20180810T143000Z to a time_t? Note that the literal always represents a UTC timestamp. I ...
0
votes
0answers
34 views

PWM C Code some logical error

I don't know what's wrong with the code I have activated all the bits I need. I want the code to slowly increase the brightness of the bulb and then reset and then the same thing goes on. Please help ...
2
votes
4answers
134 views

How to compare a string

How to compare a string coming from serial monitor with some predefined text stored as a local variable? If I say: int led = 2; String a = " abcds"; void setup(){ Serial.begin(9600); } void loop(...
0
votes
0answers
40 views

Access data using pointer from one function to another function with pointer argument

I am developing a code in which I need to access values of "add, fwc, fwa & fwv" generated by function "GetABFWversion()" in "proto485Compare()" function and pass it "proto485OnlyWrite()" ...
0
votes
1answer
26 views

Pass structure pointer as an argument to a function in c

I am developing a code in which I need to pass a structure pointer value to a function as a parameter. I am calling function "proto485Compare()" in "RS485TaskSlave()". "rs485Msg" contains my data for ...
1
vote
3answers
19k views

Number of elements in an array char

What kind of function can I use to know how many elements are in an array char? sizeof() gives the number of 'spaces' available so it doesn't work for me.
0
votes
1answer
299 views

'RtcDateTime' does not name a type

I've tested a code that compiles successfully. But after i merged it to another code, here it shown an error says RtcDateTime doesn't name a type. Used library : https://github.com/Makuna/Rtc Some ...
0
votes
1answer
22 views

Question on pin management using PCA9534PW IO Extender

There is an IO expander PCA9534PW, Arduino UNO. I don’t really understand how I can manage this expander using UNO over I2C. I found an example, but here is the reading mode. What I need: Set the ...
1
vote
1answer
241 views

Cannot obtain reading from meter (Modbus)

I have a system in which I am taking readings from a meter and processing it through an Arduino Nano. My code looks as follows: #include <SoftwareSerial.h> #define SerialControl 7 #define ...
1
vote
1answer
165 views

Length of uint8_t* const array

I've an array of type uint8_t* const with 6 items, defined like this uint8_t* const neighbourSet[] = {PEER1, PEER2, PEER3, PEER4, PEER5, PEER6}; Whereas each element in this array is static uint8_t ...
-2
votes
1answer
33 views

Using two leds with one push button [closed]

How can I make the code of this project where I will press one time a button, to turn on the first led (and turn off second led) and when other one press to turn on second led (and turn off the first ...
8
votes
2answers
3k views

Arduino interruption (on pin change)

I use the interrupt function to fill an array with values received from digitalRead(). void setup() { Serial.begin(115200); attachInterrupt(0, test_func, CHANGE); } void ...
0
votes
4answers
5k views

max7219 chained display showing mirrored text

I'm using a max7219 like this one max7219. When I first tested my circuit, I used an 8x8 display and the code worked just fine. Now, after I modified the code with the one that can be found online at ...
0
votes
2answers
1k views

Arduino UNO + Ethernet Shield + LCD + RFID but RFID doesn't work

I've been working to a project that uses arduino for RFID but when connected to ethernet shield, the RFID seems to not read any card tapped to sensor but the LCD seems to do fine. Here's the code I ...
0
votes
1answer
42 views

C: No communication to a connected serial port?

I'm trying to connect to an arduino Mega At2560 unit connected via usb serial port in my linux based PC. Using C code, I'm trying to send and receive simple text strings, just I'm able to send and ...
3
votes
1answer
783 views

Using map for DC motor instead of servo

I am trying to use map command which is used to power servo 180 degrees as the potentiometer moves... in fact what i want to do is just when i adjust my potentiometer to zero; stop the dc motor then ...
0
votes
1answer
46 views

When does a pre/post increment occur? [closed]

Editing here to clarify. The headline asks the question but the example given was not ideal. This was a more general Q than about the example code. Compilers have sequence points, places where you ...
0
votes
1answer
70 views

Random number/sequence output

The program I'm trying to build is: Type in 1st name, hit enter, type in 2nd name and then hit enter again. Register those names from string input to char naming in student struct. Print out the ...
1
vote
3answers
380 views

Why does my LED turn off automatically after about 18 seconds on its own?

I am using the Arduino Due and I am programming it with Atmel Studio 6.2. I have had a HUGE learning curve using this IDE and the Atmel ASF. Nothing is straightforward as it is in the Arduino IDE. ...
1
vote
3answers
79 views

How to assign text stored in a local file to a string at compile time

I'm developing a program that uses the HTML server in the WiFi101 library. My hardware does not have SD card storage so all source html needs to be stored as strings in the sketch at compile time. ...
4
votes
2answers
3k views

“EVERY_N_MILLISECONDS”

One of the FastLED examples that I've seen was using code that looks like this: EVERY_N_MILLISECONDS( 300 ) { transition_step(); } I've copied it and successfully used it in the same context - but ...
0
votes
1answer
30 views

What's going wrong with my EEPROM?

I've been chipping away at a project for a long time now and I've found a serious bug. Basically the user has an 8x8 grid, and each cell in this grid has a number of properties. I want to be able ...
0
votes
1answer
68 views

Read Serial data from an arduino with c code

I am trying to receive data through the serial port from my SBC (a TS-7200), i am working with linux and handle serial communication using C/C++.To send data to the SBC i'am using an arduino uno. So ...
0
votes
1answer
23 views

Can you save data to heap section in Arduino memory?

On normal computers, heap will be cleaned as you close the program, but can I save data to Arduino's heap with malloc function. And will it be cleaned after I power off the Arduino?
0
votes
1answer
62 views

How to handle concurrent HTTP request when using interrupt

I'm trying to make a door sensor with a reed switch. Each time the there is a change, the ESP8266 sends an HTTP request to web service. Unfortunately, the ESP8266 serial monitor dumps a huge stack ...
0
votes
0answers
2k views

IOT-GA6 gsm module Arduino +CME error 58

I've recently bought a IOT-GA6 gsm module . I want to use it to send an mms but doesn't work. The SMS and call work. When I execute the void function (mms) the monitor shows the error message +CME ...
0
votes
0answers
43 views

append a String on ArduinoJson Object value

I've a json string request coming from server and I convert it into json object StaticJsonBuffer<500> jsonStaticBuffer; JsonObject& root = jsonStaticBuffer.parseObject(String(msg)); ...
0
votes
0answers
55 views

Double precision floating point operations using Arduino

Today we were programming something in university which dealt with really large numbers (even larger than unsigned long) and we had to create a code that broke the numbers into an array and performed ...
0
votes
1answer
191 views

Read Multiple Sensors Data from a text file located in SD Card in Arduino/ESP32

I am working on a small home project 'glucose meter' via non invasive techniques. I am using four sensors like RGB color sensor, two multi-wavelength photo diodes (A & B) and temperature sensor (K-...
0
votes
1answer
52 views

Value assignment on Arduino

I have a thermocouple k. I want this thermocouple to select the first value OF TEMPERATURE that it read and assign it to a variable in an Arduino program. How should I do that?
0
votes
3answers
128 views

Creating a library for arduino

I found a really nice 24 bit I2C adc which was fairly cheap as well (ADS1219) but as far as I could tell there are no libraries for it so I decided to make my own. I have managed to write functions ...
1
vote
1answer
3k views

how to send argument to ESP8266WebServer objects on function

this probably simple thing to do however I can't think of a way to pass argument to function call ESP8266WebServer server ( 80 ); void toggleRelayOne() { char temp[400]; String msg = ""; if (...
1
vote
0answers
25 views

Low Level programming - MKR Fox1200

I'm working on a project using this board and wish to do so on a low level ,as in enabling certain registers to enable interrupts etc. I can't seem to find the correct header files to support ...
0
votes
2answers
135 views

How do i send ads1115 data over spi to master arduino

I am trying to send ADS 1115 data which is connected with Arduino mega_1 over I2C and arduino Mega_1 is connected with arduino Mega_0 over SPI. Arduino Mega_1 is act as a slave and send ADS 1115 data ...
1
vote
3answers
485 views

Why to store a function parameter value in a class private variable?

I'm just curious, I'm going through a C++ library for the mcu2.4 TFT display. And this method I notice when I run through C++ libraries. Which is when a parameter is passed through a function, it's ...
1
vote
0answers
72 views

Why does the program size increase so drastically with these switch-cases?

EDIT: The problem is my op-code catch is op >= 0x20 || op <= 0x2F rather than op >= 0x20 && op <= 0x2F and so most of the switch-case was being optimised away! This is a really ...
0
votes
1answer
37 views

Optocoupler on Tinkercad acting weird

So, maybe it's my understanding that is at fault or maybe it's tinkercad. It's probably the former. But anyway here's my problem I've connected it according to picture https://imgur.com/a/h2HYgUE ...
0
votes
1answer
108 views

How can I concatenate these two values as a string?

I've tried all the supposed solutions for the exact error, pasted into google, that I could find on every forum including this one and no matter the alleged solution I will either get the error about ...
0
votes
2answers
41 views

Button state changes despite not being connected?

I have written some code to test buttons that I want to use const int buttonPin1 = 1; const int buttonPin2 = 2; const int buttonPin3 = 3; const int buttonPin4 = 4; const int buttonPin5 = 5; const ...
-1
votes
2answers
4k views

Peer to peer communication

Hello guys , I want to perform a mesh network between 3-4 modules using ESP8266 . Any one have idea how to do it?
1
vote
2answers
2k views

Using an Arduino for learning embedded C programming

I'm a computer systems engineering student and was planning to buy an Arduino to learn embedded C programming. After researching I found mention that an Arduino may not be a good choice for a beginner ...
11
votes
5answers
6k views

Arduino: How to get the board type in code

I want to write a sketch that can be compiled on different Arduino boards. I want to display on the PC which board is currently connected. This means that the user connects the PC via USB cable to ...
1
vote
3answers
401 views

Code for a rolling average

Below is some code I wrote to find the rolling average of a temp sensor hooked up to an arduino and display it to an lcd display. My issue is that for the first minute it is running, the average is ...
0
votes
1answer
650 views

Integer array definitions: Length

I'm defining a variable as integer and want to use thati int specLength = 17; int spec[specLength-1]; When I do this, I get the following error message: TestProgram:34: error: array bound is not ...
0
votes
1answer
52 views

Formula creation

I was creating a scoring formula for a game. The formula in question is millis() * 1.1 ^ (millis()/10000); However, I'm having trouble understanding the different error messages that the Arduino ...
1
vote
1answer
427 views

How do I directly access a memory mapped register of AVR with C

Assume I want to write the following without using DDRD or PORTD: #include <avr/io.h> #include <util/delay.h> int main(void) { DDRD = 0xFF; PORTD = 0xFF; } I found this link ...
1
vote
1answer
2k views

AVR timer overflow interrupt not working

My problem is an interrupt service routine (ISR) that seemingly never executes! Here's some info on my set up: I am flashing an avr attiny85. I have the bare bones of a project set up so far with ...
1
vote
1answer
154 views

How is it possible to access the CPU registers using memory addresses?

The following is taken from ATmega328-328P Data sheet. According to this, I can access all the 32 registers in CPU using memory addresses. For example: unsigned char *register = 0x0; will access ...
1
vote
1answer
46 views

How is a long int stored in an 8 bit Arduino register

Assume the following code in C: long int a = 262143; which in binary will be 111111111111111111 (18 bits). If an atmega328p register can hold 8 bits, how is the above represented in the register? ...