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.

0
votes
0answers
15 views

Nrf24l01 interfacing with arduino [on hold]

Can we calculate the distance between 2 nrf24l01 modules and work accordingly..? I have tried the testcarrier function but it didn't give me any values
0
votes
1answer
20 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 ...
-2
votes
1answer
31 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 ...
1
vote
1answer
45 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 ...
1
vote
1answer
116 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 ...
0
votes
1answer
154 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
69 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 ...
0
votes
1answer
28 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 ...
1
vote
3answers
77 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. ...
0
votes
1answer
60 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
21 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
41 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 ...
0
votes
1answer
47 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
32 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
45 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
3answers
112 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
0answers
24 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 ...
1
vote
3answers
464 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
69 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
34 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
82 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 ...
0
votes
1answer
50 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
1answer
165 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-...
1
vote
3answers
275 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
50 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
330 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
130 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? ...
0
votes
1answer
79 views

ESP8266 12-E can't connect to any Access Point with converted variables from strings to char arrays

I'm using an esp8266 12-E nodemcu I wrote a code that scans the available WiFi networks, print them through serial communication,ask the user which network he wants to connect to and then the password ...
1
vote
2answers
66 views

Why is there no embedded c code in arduino libraries?

When I took a look at how the arduino libraries were coded I expected to see register names like I/O registers(PINx,DDRx,PORTx) and other such registers with values assigned to them but instead I saw ...
0
votes
6answers
548 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
3answers
2k views

How to convert byte *payload to String

I would like to convert a byte *payload to a String, because I want to compare the content of payload to another String. void mqttCallbackHandler(char *topic, byte *payload, unsigned int length) { ...
0
votes
2answers
127 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 ...
2
votes
2answers
506 views

Print with round towards zero instead of round to nearest

When printing with one decimal place, Arduino's Serial.println() rounds numbers like 123.89 to “123.9”. Is there any way to change the rounding mode? For some reasons I want the value to be rounded ...
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
2answers
292 views

Can i use a range in a switchcase like in pascal?

in pascal's case statement i can use this: Var i : integer; ... Case i of 1..5 : DoSomething; end; i was wondering if there is a way in can do this with c/c++ in the arduino compiler using:...
0
votes
1answer
1k views

“function” was not declared in this scope (called in setup)

I have this bit of code I'm trying to execute only once. but I seem to get this error every time I try to compile: "calcOppervlakte' was not declared in this scope" when it's being called in the setup....
-1
votes
2answers
42 views

Do prototypes need to follow the order of the functions? [closed]

I define prototypes prior to calling the functions. Does the order of the prototypes have to match the order of the functions in the code? I'd like to sort the prototypes alphabetically, while I ...
0
votes
1answer
379 views

ToF VL53L1X sensor integrate with arduino

I have this latest version VL53L1X time of flight laser distance sensor: http://www.st.com/en/imaging-and-photonics-solutions/vl53l1x.html I study about this sensor, It says that sensor only Access ...
0
votes
1answer
501 views

How to write Arduino API code in VL53L1X?

I'm trying write code for the VL53L1X on Arduino, but I didn't get the VL53L1X registers. How to access them and how to measure the data in VL53L1X? Can anyone help me?
0
votes
1answer
52 views

Connect BotBoarduino with servos and Ultrasonic sensor HC-SR04

I am new to Arduino and I am making a Walking Quadruped using BotBoarduino as microcontroller. I want to install an Ultrasonic Sensor HC-SR04 so that it will stop when an obstacle is detected. I have ...
2
votes
2answers
362 views

Digital Band pass filter arduino 1100-1300 Hz

For a project I need to design an digital band pass filter. I started of with this in Matlab: wch=1100*2*pi; wcl=1300*2*pi; sys=tf([1/wch 0],[1/(wch*wcl) 1/wch+1/wcl 1]) sysd=c2d(sys,9615,'tustin') ...
0
votes
0answers
122 views

Using 4 identical sensors on the I2C bus

I am using 4 Pololu VL6180X ToF sensors on the Arduino UNO for a school project but just can't seem to get it working correctly. I understand that I need to hold them in reset and change the I2C ...
-9
votes
1answer
211 views

Arduino arrays not working for some reason [closed]

Why does int x[5]; x[0] = 10; is not working. If im doing something wrong i cant figure out what it is.
0
votes
2answers
32 views

Error array value after passed to a function

I would like to ask about a weirdness in my program. This is my program: void setup() { Serial.begin(9600); } void loop() { workout_Text(); } void workout_Text() { int woT_x[] = {1, 4, 8, 12,...
0
votes
1answer
729 views

Problem converting character array into integer in arduino using atoi function

I'm receiving a character string from a radio signal on my arduino. This character string consists of four character digits, which I want to convert into an integer. The four digit sequence may ...
0
votes
0answers
75 views

Several things with delays in millis()

I have several readings from some sensors. The goal is to print them one by one with a delay of 3 sec. It is fairly easy to do, but the problem is that there is a button and if i set those delays with ...
-3
votes
2answers
60 views

Every loop other case [closed]

I need to achieve that in every loop my Arduino do other thing. Say in first loop do one thing, in second do second thing and in third loop do third thing. And again. And while doing one thing, other ...
4
votes
2answers
2k views

Properly using separate tabs with Arduino IDE

I'm trying to split up a large project of mine into separate tabs in the Arduino IDE and I'm having more than a few troubles with it. My main trouble is finding a way to have routines in extra tabs ...