Stack Exchange Network

Stack Exchange network consists of 174 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
1answer
30 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
14 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
17 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
33 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
75 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
21 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
397 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
64 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
31 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
46 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
36 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
49 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
94 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
123 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
46 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
174 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
86 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
43 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
67 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
60 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
338 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
1k 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
107 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
412 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
1k 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
193 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
864 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
337 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
435 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
47 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
281 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
98 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 ...
-8
votes
1answer
164 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
640 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
71 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
59 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
1k 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 ...
0
votes
1answer
182 views

How to scroll data in LED dot matrix through multiple modules?

I've been struggling in this issue for a long time, I know there are people who have done it. But, I don't have much experience in C to have the skills to design or develop such complicated functions....
1
vote
1answer
879 views

avr/io.h No such file or directory error when compiling using avr-gcc

I am trying to use the atmega328p as standalone microchip and program it. I ama using an Arduino Uno as ISP. I have written a simple program to test it however when I try to compile it using avr-gcc ...
2
votes
1answer
462 views

How to calculate actual Baud Rate and its percent error?

I am using an Arduino Uno, and I need to create a program that calculates the actual baud rate and the percent error for all standard baud rate in Arduino monitor program.
3
votes
0answers
669 views

Send custom 802.11 data frame with ESP8266 [closed]

I would like to send raw 802.11 data frames in order to transmit pictures with the ESP8266. I have the Espressif SDK 1.3 and so far I have tried to construct a packet and send it with ...
0
votes
1answer
99 views

Trouble with Arduino -> PSOC4 communications over I2C! (Multi master/ slave config)

Hello Stack Exchangers! I am currently working on a project which requires me to use PSOC4 - 049's to scan a series of inputs, and feed this data back to an arduino over I2C. The arduino, or in ...
0
votes
0answers
682 views

ESP8266 ADC read analog

I have a 24CL256 external EEPROM, to which I wish to write 30,000 bytes of 8-bit data, reading from the built-in ADC of an ESP8266. Here is my code: void setup() { Serial.begin(115200); Wire....
1
vote
2answers
1k views

DAC to play audio samples

I have a buffer which contains 16000 PCM samples of 8Khz 8-bit mono. I am trying to play it using 12 bit MCP4725 DAC. I have tried using micros() to control the write interval for the DAC. Here's my ...
1
vote
1answer
106 views

Is output pin set to LOW grounded

If I do following: pinMode(MYPIN, OUTPUT) digitalWrite(MYPIN, LOW) What will happen? Will this effectively ground MYPIN or output some low voltage?
0
votes
0answers
48 views

How to keep Arduino buzzer off if changes are less than 3%?

I am using the following sketch to monitor water level in a tank. It triggers the buzzer if water level crosses 99%. If the water level is at 100%, the buzzer will turn of after few seconds, but it ...
0
votes
3answers
2k views

How to communicate with ESP8266 ESP01 by sending data through softwareserial on Arduino Uno?

I am able to send AT commands when connecting to the software through the TX/RX pins (1, 0) and the ESP01 communicates perfectly. However, as soon as I start doing that same thing with code I can't ...
0
votes
2answers
84 views

Unable to read data with 16 serial clock cycles

I am trying to read data from an AD7314 Temperature Sensor that is connected to an Arduino Uno and output that value onto 6 LEDs also connected to the Arduino Uno board. From the image below, the ...