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
1
vote
1answer
33 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[...
0
votes
0answers
25 views

relay not working

i tested 6 and none work. #include "Wire.h" #include "LCD.h" #include "LiquidCrystal_I2C.h" #include <Keypad.h> #define A0 A0 #define A1 A1 #define A2 A2 #...
2
votes
0answers
31 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
24 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
36 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. ...
3
votes
2answers
383 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
34 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
145 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
858 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
95 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
49 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 ...
1
vote
0answers
55 views

Arduino mega reads ps/2 keyboard in C without arduino library [closed]

I want to read the input of an ps/2 keyboard. I connect the keyboard by a connector to arduino mega 2560. Clk to pin 2 and data to 30. Now my question how can i program in C that when I click any key ...
3
votes
2answers
355 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
126 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
45 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
89 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
31 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
60 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
490 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
293 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
333 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
64 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
616 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
141 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
331 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
49 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
84 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
181 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
389 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
43 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
114 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
39 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
91 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
46 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
43 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 ...
0
votes
1answer
357 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
443 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
305 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
180 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
143 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
37 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
53 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 ...
0
votes
2answers
285 views

Arduino stops sending/receiving data over Serialport after random time

I got a C# WPF application wich communcates with my arduino uno over serial port. Everything works fine for 3 to 20 seconds then i can not send or receive anything from/to the arduino. What im trying ...
0
votes
1answer
297 views

Can't use uint16_t in library

I wonder why the following minimal example sketch doesn't compile (unknown type name 'uint16_t'): sketch_does_not_compile.ino: #include "myheader.h" void setup() { char a[]="hello world"; ...
1
vote
2answers
72 views

Mixed structure with int and string

I want to create a structure like this: struct commands { int cmd; char descr[25]; }; commands cmds[] = { {16, "Hammond Organ"}, {17, "Percussive Organ"}, {18, "Rock Organ"}, { 0, "" ...
0
votes
1answer
166 views

Scope of RtcDateTime object when declared outside of a function

I'm trying to merge 2 Arduino samples, in order to be able to use DS3231 RTC module with ESP8266 WiFi simple web server. My RTC library is this: https://github.com/Makuna/Rtc/wiki Generally, to code ...
1
vote
0answers
74 views

ESP8266-01 Serial.print returns a blank given a valid string

I am currently trying to create a led matrix with ws2812b leds. I am using an uno on the rear of the display to control the leds and now I want to add wifi capabilities. Since I already had serial ...
0
votes
1answer
174 views

String to Dynamic Byte array

I'm new in Arduino stuck in String to a dynamic byte array. My String: String Finalval="6D616320747820636E662031352033300D0A"; Dynamic Byte array: byte ft[]={0x6D,0x61,0x63,0x20,0x74,0x78,0x20,...

1
2 3 4 5
9