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
2answers
32 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
33 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
41 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
64 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
41 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
105 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
63 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
41 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
49 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
57 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
204 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
676 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
70 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
363 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
816 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
118 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
495 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
37 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
295 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
371 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
43 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
240 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
82 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
115 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
542 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
1answer
69 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
860 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
143 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
704 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
395 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
543 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
90 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
593 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
835 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
104 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
47 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
1k 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
77 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 ...
0
votes
1answer
172 views

Why does void loop() stop after some samples?

I am not getting any compile time error. After some samples of data void loop() stops executing. Please let know what the problem is. Below is my code. Thanks and regards Thippeswamy #include<SPI....
0
votes
1answer
527 views

SPI Temperature sensor interface with Arduino Uno

I want to interface with an AD7314 Temperature Sensor. I want to only read the temperature value from the sensor and output the value on to 8 LEDs connected to the Arduino. But so far I have not been ...
0
votes
1answer
56 views

Not clear code procedure in Arduino wire library

The application code of sparkFun, has the following line which is difficult to understand. It's requested 6, because it's requesting 6 bytes for HMC5883L module. Wire.requestFrom(address, 6); if(6&...
0
votes
1answer
20 views

Is this a good function for I2C receive?

I'm trying to fix my I2C code: Is the following function correct because it has multiple returns. I don't know if that would work. uint8_t I2C_rx(uint8_t ack_rx) { uint8_t i; if (ack_rx) ...
0
votes
1answer
452 views

Checksum is wrong - Air Quality Monitoring Station PMS5003, BME280 | Code review

I working at air quality station. I measure particulate matter with PMS5003 and meteorological parameters with BME280. Everything seems to work just fine, but sometimes program hangs on checksum ...
0
votes
2answers
161 views

Difference between ISR and other functions in AVR twi library

I was studying the ISR for twi and I want to know how is it working. I have two questions about the code handling for ISR and the other functions and what they do exactly: My first question is about ...
0
votes
2answers
159 views

Speed measurement from lidar sensor for automatic braking system

For a school project I have been working on a system that will automatically brake when there is danger. Only the requirements are more strict (safety) than just using a ping sensor and detecting a ...
0
votes
1answer
275 views

Why using static volatile for variables and only static for arrays in TWI library?

I want to know why to declare variables with static volatile and arrays with only static in TWI library? For example; static uint8_t twi_masterBuffer[TWI_BUFFER_LENGTH]; static volatile uint8_t ...
0
votes
1answer
446 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
2answers
85 views

Why it's not possible to manipulate the TWSR directly? [closed]

I think I forgot the reason for this SFR manipulation in microcontrollers; like, checking the TWSR in twi. The technique for checking the values of the TWSR is by masking it with another variable or ...