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.

Filter by
Sorted by
Tagged with
0
votes
1answer
41 views

On-device logging of all Serial.print calls? [closed]

My Arduino program produces debug/error output using methods like Serial.printf. I can see all this output when it's connected to the computer, but I want to also log all this same output to my board'...
0
votes
0answers
49 views

Issues porting capacitive touch code from Arduino to avr

I'm trying to port GreatScott's capacitive touch code to avr. From my understanding the timer is constantly generating a pulse via the TIMER1_COMPA interrupt and the circuit works when I test it ...
1
vote
1answer
137 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....
12
votes
6answers
3k views

Using String instead of C string, yet another attempt to touch a loaded issue

I've been reading a lot over the years why we should not use the notorious String class and how heap fragmentation is bad practice and not professional and we should never use it in our programs or we'...
1
vote
1answer
384 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
2answers
906 views

How to write nonblocking code, for polling sensor at 100 Hz

I'm using this piece of code to try to poll an IMU sensor at 100 Hz (for a AHRS sensor fusion library). void loop(void) { // nonblocking code variables static uint32_t last_ms; uint32_t ms; // ...
-2
votes
1answer
77 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
0answers
29 views

1 Button + Potentiometer [duplicate]

Sketch arduino-uno programming 1 Button and 1 Potentiometer Sketch: Each time the button is pressed, acquire the value of the potentiometer in a array of 10 positions of these values do the average ...
1
vote
1answer
40 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[...
2
votes
1answer
47 views

Arduino buzzer code sequence not triggering

I have a problem with my arduino buzzer: the code should be doing the following: I have a security system where in order to open the door you have to enter a 4 digit code from the remote. If the code ...
1
vote
0answers
30 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 ...
0
votes
1answer
154 views

esp32s: error: 'WDT_TIMEOUT' was not declared in this scope

I am trying to initialize the watchdog timer. I have installed arduino-esp32-master.zip I have #include <esp_task_wdt.h> set but it is not highlighted red indicating the IDE knows about it. ...
2
votes
2answers
1k 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++) { ...
-1
votes
1answer
62 views

Efficient workflow/tools for converting color images to hex arrays

I would like to display 65k color animated gifs on my oled. I'm using the adafruit library for https://learn.adafruit.com/096-mini-color-oled Now I need to convert a significant number of images to ...
0
votes
3answers
284 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,...
3
votes
2answers
900 views

How to upload code without closing puTTY

My question is quite simple: can you, somehow, upload Arduino code without closing puTTY's serial console? I hate having to close the program to open it again for reading the incoming information.
4
votes
1answer
105 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 ...
1
vote
0answers
55 views

Arduino LCD only display image for few second and turn screen to white

I have a problem with my Arduino and LCD touch screen. I create a few functional button in my Arduino. One of the button is START button. Right now, I want the image is display when I touch START ...
3
votes
2answers
462 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 ...
0
votes
1answer
375 views

How to include a file from another (parent) directory

This is my structure program/ src/ Makefile main.ino test.h ... lib/ i2c.h In main.ino I include test.h and in test.h I'm trying to include i2c.h but it is just not working, I ...
-1
votes
1answer
61 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
1answer
154 views

Cannot compile F() macro with R"string"

I am trying to compile the following code: logger.log_info(F(R"(some text here that may take multiple lines and here it is done.)")); But the compiler exists with the following ...
1
vote
0answers
30 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 ...
1
vote
0answers
35 views

Send message to multiple number

sim.println("AT+CMGS=\"+91xxxxxxxxxx\"\r"); I don't want to write this. I want to write mobile number on serial monitor in Arduino and on that number, i want to send message. how ...
0
votes
1answer
109 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?
2
votes
1answer
2k views

Need help: Cast from 'char*' to 'uint8_t {aka unsigned char}' loses precision [-fpermissive]

I'm trying to convert the string that I receive from the Websocket to uint8_t that I can copy to the data bytes of CAN protocol frame. I'm using an ESP32 chip and programming it on an Arduino IDE. The ...
1
vote
2answers
493 views

help explain pulseIn function with arduino and Ultrasonic sensor

dears Engineers.. i got stuck with this issue couldn't understand.. please help with explanations. first i was upset of my ultrasonic sensor reading deviations, that is i examine my sensor indoor and ...
5
votes
2answers
597 views

Jumping to bootloader from application code in atmega328p

I'm trying to program an Arduino Uno (atmega328p) using only the serial Tx/Rx lines (no DTR, so no automatic reset). This is so I can upload code via WiFi/TCP using an ESP-01. To achieve this, I need ...
2
votes
0answers
73 views

Arduino EPROM dumper with utility program in C

I am writing EPROM dumper with Arduino UNO and utility program in C and I am using Ubuntu 20.04. The Arduino sketch works fine, but I am having few problems with the utility program. The first problem ...
1
vote
1answer
1k views

Which Arduinos support ATOMIC_BLOCK?

Is there a definitive list of which Arduino architectures support the ATOMIC_BLOCK() macro, and a list of #defines for each architecture? I've tried searching through the Arduino cores on GitHub to ...
1
vote
1answer
214 views

How I can send data information without work WiFi to LCD?

Hi everyone I am beginning learn coding and the second language English. I have small project I use Arduino uno , esp8266 , dht11 , lcd I2C and use blynk app in my project I have the code and work ...
1
vote
2answers
660 views

How to convert Unicode char to “Unicode HEX Position” in Arduino

How to convert Unicode char to "Unicode HEX Position" in Arduino or C i will share a picture here : for example in JavaScript you can do that with charCodeAt(); ! this function will return ...
0
votes
2answers
52 views

Add char at intervals in a String

I'm trying to create a function that will take a String as an input, and at every 20 characters, it will instert "\n" so that the string doesn't go off the side of my screen (I'm using an ...
1
vote
0answers
138 views

How do i efficiently write this code for PS2 controller to USB convertion sketch for Arduino Pro Micro?

I am really new to coding and building stuff, so forgive me if it is anything offensive.i have been trying to convert my PS2 dualshock controller to USB using arduino. there is a library called ps2x ...
1
vote
0answers
285 views

Display GPS module data to my TFT display

I am using Arduino Mega 2560 and I have written code for my GPS module (Neo-6m-0-001/GY-NEO6MV2) and it is working fine independently. I also have written code for Compass module (QMC5883L) which is ...
0
votes
1answer
796 views

Getting error invalid conversion from 'const char*' to 'const uint8_t*

I have written this sketch, and I am trying to populate the array of wifi hotspots to set the value in html select using javascript dynamically. #include <Arduino.h> #include <Hash.h> #...
0
votes
1answer
55 views

trying to make wemos d1 code modular causes collect2: error: ld returned 1 exit status exit status 1

#include "connection.h" void setup() { Serial.begin(115200); Funcs::Connect conn; conn.connectWifi(); } void loop() { } then connection.h file: // connection.h namespace Funcs { class ...
0
votes
1answer
191 views

Is it possible to count rising edges of a 4 MHz clock on an Arduino Due and trigger an interrupt like all 4'000'000 edges?

I am struggling with my Arduino Due and the Timer Counter functionallity. The following is what I am trying to achieve: I want to execute a function to a specific point of time or more precisley ...
1
vote
1answer
44 views

Node.js cannot recognize characters from the serial port

The following script prints everything fine, it recognizes integers from the serial port, but cannot recognize characters. The if statement does not work with characters. I have tried both == and ===...
-1
votes
1answer
95 views

Data in two 8 bit shift registers won't change

I'm trying to output 16 bits of data to two 8 bit shift registers (74HC595), which drive a 8x8 led matrix. There is a problem with the way the code outputs data to the registers, its like no data is ...
1
vote
1answer
55 views

Unable to understand the acquisition of data from Magnetometer HMC5883L and Accelerometer ADXL345

Below are the X,Y,Z registers for HMC5883L. while this is the Arduino code for HMC5883L to acquire X,Y,Z reading. If you look at this code, we do not mention the X, Y, Z address specifically. ...
0
votes
1answer
48 views

Passing struct from main.cpp to a class

Sorry if this question been posted but I couldn't find the one that matches my issue. I couldn't pass my struct values from the main file to a class. Any ideas? I got this: error: no matching ...
1
vote
2answers
588 views

serial is print twice?

I have a problem , when send 1 or 0 by Bluetooth module the serial monitor print two time (RECEIVED SMS) . what's the wrong ? This is my code : char BluetoothData = 0 ; void setup() { // ...
0
votes
0answers
68 views

With what can I replace this for loop so my Arduino doesn't spit jibberish?

I have this: for (int i = 0; i < (DELAY_SIZE - 1); i++) { if (check_tag_in_char(delay_chars[i], BOOK_UPLOAD_END_TAG)) { tag_pos = 0; Serial.println("Uploaded"); ...
4
votes
4answers
707 views

How can I set up outputs without using digitalWrite?

Consider the following: #define IN1 9 #define IN2 10 pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); void LeftMotor(Direction direction) { digitalWrite(IN1, direction == Forward ? LOW : HIGH); ...
-1
votes
1answer
361 views

esp8266 ip address issues

I have android studio app and arduino codes they are connected to each other using esp8266 but it works only on one network when I use another network it doesn't recognise it's ip address instead it ...
1
vote
2answers
237 views

Serial loopback not working with jumper wires connected

I'm a beginner to Arduino programming. Before attempting anything more complex I'm trying to get some very basic functionality first, so using some of the sketchbook examples I'm trying to get the ...
-1
votes
1answer
202 views

Is it permissible to use strlcpy to copy an array to itself? [closed]

Task: delete "\n" at the beginning of the array. Example: char s_msg[15] = "\nHello world!"; void setup() { Serial.begin(115200); Serial.println("Load"); // Search \n if(strstr(s_msg, "\n") ...
0
votes
1answer
42 views

The problem of not saving the previous value when sending it from bluetooth

Controlling Led's from Buttons and Bluetooth by same method The problem now : the LED light up when you send an A over Bluetooth and it will turn off after 2 sec automatically without you doing ...
0
votes
2answers
55 views

A problem with measuring time in a for loop

I am familiar with timing using millis() function, but it seems that I have run into a problem with a for loop. The thing is, I am comparing encoder readings with a value entered via 4x4 keypad. Since ...

1
2 3 4 5
9