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.
431 questions
0
votes
1
answer
125
views
Serialise a struct containing a flexible array
I want to serialise and deserialise a struct containing a flexible array.
I did find a working code but wondering if it is the most elegant and optimum way to do it.
This is my first attempt below ...
0
votes
1
answer
116
views
Problem with char* variable malloc/free. Empty contents on recipient variable after using free
I am working on a custom SD card data logger using the following function and struct:
char *filenameCreator(const char *prefix, const char *num, bool addExtension)
{
char *filename = (char *)...
-1
votes
1
answer
360
views
Declaration of global variables in separate file: compiler conflict
So I have:
1/ My myapp.ino file, that includes src.h (implemented in src.cpp). Compiled for Arduino Uno.
2/ I also have a unit-tests.cpp file that is meant to test functions in src.cpp. Compiled for ...
2
votes
2
answers
6k
views
How to use Interrupt in Arduino to receive the data from Serial Input
Currently i have a project that forced me to make a program that receives several data from Serial Input using Interrupt in Arduino. I use Arduino as the receiver and ESP32 as the sender through ...
4
votes
1
answer
692
views
Problem with reading data from ELM327
The idea was to create a bluetooth device on the arduino to read data from the machine (ELM327 v2.1) using the HC-05 bluetooth module.
In this code the bluetooth module is switched to MASTER mode and ...
1
vote
0
answers
68
views
How to prevent the application code from getting stuck in forever loop when using SerialFlash library in Arduino-Adafruit framework
I have been working on a project that runs on Adafruit's Bluefruit nRF52 board. I used the SerialFlash library for Arduino provided by Paul Stoffregen: https://github.com/PaulStoffregen/SerialFlash....
2
votes
1
answer
283
views
How does the compiler/assembler work wrt bootloader?
I realized that on the atmega boards the bootloader is programmed into the chip.
I'm curious, when compiling a sketch how does the compiler/assembler differ from compiling a standard C program for a ...
-1
votes
1
answer
392
views
How to write arduino code in a c/c++ script
I'm pretty new to arduino. But I have some knowledge about programming in c/c++. I know that arduino is written in c. But it can't be used as normal c/c++ code.
for example ,
instead of including some ...
-1
votes
1
answer
113
views
Can't get input from 4x4 keyboard
I'd like to make some basic calculator. Currently, I'm struggling with inputs. I wanted to get from user some numerical input, then, I'd like to have an information, which type of calculation he is ...
2
votes
1
answer
493
views
How to process 20-bit sensor data
I have an acceleration sensor (ADXL355) that returns 20-bit data in three bytes, formatted as 2s complement :
acc3 (bits 19-12) in byte register 3 (mapped to bits 7-0)
acc2 (bits 11-4) in byte ...
0
votes
1
answer
86
views
Do I need to use resisters and ICes for specific sensors.What if I dont use it,Will it impact my arduino board some how like making it useless &faulty
So I was reading about Simple AutomaticLight Controller using LDR. or with the help of LDRSenso. But I have LM393 Photoresistor (LDR) Sensor I like to know are they same thing or somewhat different. ...
3
votes
1
answer
3k
views
How to build an arduino project with multiple source files?
I'm building an arduino program on linux, using the following Makefile:
ARDUINO_DIR = /usr/share/arduino
BOARD_TAG = uno
ARDUINO_PORT = /dev/ttyAMA0
ARDUINO_LIBS = Wire
include /usr/share/arduino/...
1
vote
0
answers
274
views
I can get arduino code/board to show voltage using analog input but not python/board
I am trying to simply read a voltage from a battery. I am able to work out how to do this using arduino code on an arduino board. (UNO)
When I try to do the same thing on a board using python the ...
1
vote
1
answer
2k
views
How to fade LED in a defined time using FastLED
I'm using FastLED library, Arduino Nano and 5 addressable LEDs (WS2812B).
I'd like to create the sequence in the image attached. (all in white color for example)
I know how to turn ON each LED every 0....
2
votes
1
answer
5k
views
Arduino parsing of a string using sscanf
Hello I am new to Arduino and C programming.
I wanted to parse string using sscanf fuction
This is my Program
String hith;
int field1,field2;
float field3;
int F1=0,F2=0;
float F3=0;
int h1,h3;
float ...
-2
votes
1
answer
872
views
Do I use an LED or a pullup resistor for stopping "floating" or "ghosting" for a matrix keypad?
I know this sounds simple, but I have an Arduino Mega 2560 and I am making a matrix keypad for a claw machine. It's a 3*4 matrix keypad. Let's just say, I am making this keypad for the claw machine to ...
1
vote
1
answer
181
views
int array passed through function has wrong values only after multiple passes
I have this code:
for(int i = 0; i < its; i++) {
x1 = random(0,4);
y1 = random(0,4);
multiLamp(new int[2] {3,1}, new int[2] {x1,x2}, new int[2] {y1,y2}, wait, 2);
multiLamp(new int[...
1
vote
0
answers
376
views
Having trouble compiling in VsCode when including arduino libraries. (Win10)
I recently switched over to Visual studio code and away from the arduino IDE though I am a novice at both. When using VSC and the neopixel library and sample code(strandtest) containing animations ...
2
votes
2
answers
5k
views
Difference between char array and unsigned char array [closed]
I have written a small test code for Arduino Uno which is as follows:
unsigned char tes[4];
char testing[4];
void setup() {
Serial.begin(9600);
for (int i = 0; i < 4; i++) {
...
0
votes
3
answers
1k
views
Run multiple function with different argument/return structure by one function pointer
Edit:
I tried a simple code in Arduino IDE which should've done in the first place instead in doing it in a desktop compiler. Because the results are different by experiment. In the desktop C compiler,...
4
votes
1
answer
1k
views
Why does Arduino round off some integers but not others when my desktop PC does not do this?
I am writing (in C) some low level digit manipulation routines that convert int to float and vice versa for Arduino. I came across some puzzling behaviour with Arduino rounding some numbers but not ...
3
votes
2
answers
1k
views
Switch case options get broken after a function call
I'm sorry for the basic question, but I have a switch case where any code placed after a certain function call simply never gets called, and I've spent half a day looking at it, so thank you so much ...
-1
votes
1
answer
276
views
Arduino waits until button release to activate
I'm fairly new to arduino, and on my own I'm trying to move a servo to the left and right using 2 buttons. I've got it working for the most part, however when I hold the button down nothing happens, ...
1
vote
0
answers
56
views
serially parse integer after serially read
I want to write below code but I don't know where I doing wrong, so please help me solve this issue.
Serially read some text like number then I want to serially parse integer value into some variable ...
0
votes
1
answer
598
views
Arduino + Codeblocks C++
I'm writing the code for my Arduino board using Code::Blocks editor. When I create a new project, there is AVR Project and Arduino Project under Projects category. Which one do I select?