All Questions
Tagged with programming c
102
questions
0
votes
1
answer
51
views
SPI with DMA in a Arduino Due
I have a project where I need to store data (~16Mo) on a memory and be able to fetch the data fast (<36000bits/s) with DMA because I have other signals to take care of.
Currently I use a SD card ...
2
votes
1
answer
2k
views
lcd.createChar() only allows for 8 custom characters
I have a teensy4.1, with a 16 by 2 LCD screen, and an I2C LCD interface.
I was trying to write a bunch of custom characters to an LCD screen, to flip some text.
my issue is that it works fine, but on ...
2
votes
1
answer
2k
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
1
answer
71
views
Morse encoder code not working as expected on Arduino UNO [closed]
I'll start saying that I don't have much experience working with Arduino and programming in C. I have an Elegoo Arduino UNO clone.
Recently I was trying to build a morse encode which converts a text ...
2
votes
1
answer
3k
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
102
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
votes
1
answer
159
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 ...
4
votes
1
answer
407
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 ...
0
votes
1
answer
423
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?
1
vote
2
answers
956
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 ...
2
votes
3
answers
2k
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
1
answer
2k
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
1
answer
89
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 ...
1
vote
1
answer
298
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 ===...
0
votes
0
answers
72
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");
...
-1
votes
1
answer
379
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
2
answers
65
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 ...
2
votes
2
answers
616
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, "" ...
1
vote
0
answers
398
views
SPI communication with Arduino and PGA411-Q1 resolver sensor
I have been trying to implement SPI communication between an Arduino board and a PGA411-Q1 resolver sensor board. I have set up the Arduino SPI settings as indicated on the resolver sensor's datasheet ...
0
votes
1
answer
49
views
Is if statement correct?
if(temperature < baselineTemp)else{
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}else if(temperature >= baselineTemp+2 && temperature < baselineTemp+4){
...
1
vote
0
answers
45
views
Where is tcp.c?
This question is related to my other question, which I already answered.
I want to add modify tcp.c to include my own code. The problem is I can't find tcp.c. The first thing I tried was looking in ...
5
votes
3
answers
33k
views
How do I extract code from an arduino? [duplicate]
I updated and uploaded some code on another computer that got wiped and didn't send the new code to my current computer, the updated code is still on the board but I don't have access to it. How do I ...
0
votes
1
answer
329
views
How can I stop a loop when using a servo with a Key input?
How can I stop my following code using a key?
Basically the code should run the servo in a loop if "t" is pressed and stop the loop if "s" is pressed.
#include <Servo.h>
Servo myservo; // ...
1
vote
2
answers
687
views
How do I implement reverse enumeration?
Basically I'm trying to output a string based upon a value in an array, the following code is what I have come up with to achieve my desired result, but I have a feeling that there is a better way to ...
3
votes
3
answers
2k
views
Variable declaration inside main loop
In the past I declared variables inside the main loop which worked just fine.
In a new project I did the same:
void loop(void)
{
uint8_t counter;
....
if (buttonPress)
counter = 0;...
0
votes
1
answer
2k
views
Rounding float number
I want to enable user to change the duration of PWM from 0 to 255, the number should be in minute and increase/decrease with two push buttons.
(X) x 255 / 60000 = minute
In above example each time ...
1
vote
1
answer
352
views
Problems with Serial.read()
void loop()
{
if (sensor.begin() == true)
{
Serial.print("Current Conversion Mode: ");
Serial.println(sensor.getConversionMode());
Serial.println("Enter your mode of Conversion (number ...
0
votes
1
answer
63
views
Split serial monitor output to only save part of the output
This is the output i get from the serial monitor from using a HM10 in . How could i go about splitting the data using arduino uno. I only want to save the last 12 digits before the :- (4CAA0DE091B7) ...
1
vote
0
answers
780
views
UDP Packet not receiving
I started a project where I wanted to send sensor data from one arduino to another and let this 2nd Arduino send the data to a tablet to visualize sensordata like speed, temperature etc.
I wanted to ...
1
vote
1
answer
763
views
Working with Wire core library
I'm studying the Wire library code driver utility/twi.h to learn how twi buffering and ISR management work.
What I did actually, is that I copied the header/source files from the Arduino path F:\...
0
votes
1
answer
114
views
When does a pre/post increment occur? [closed]
Editing here to clarify. The headline asks the question but the example given was not ideal. This was a more general Q than about the example code.
Compilers have sequence points, places where you ...
0
votes
1
answer
136
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
1
answer
5k
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
2
answers
404
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 ...
2
votes
2
answers
1k
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')
...
1
vote
0
answers
246
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 ...
0
votes
2
answers
37
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,...
2
votes
1
answer
1k
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.
0
votes
1
answer
765
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
1
answer
3k
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
1
answer
2k
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
2
answers
4k
views
Max length of char arrays?
I'm running the following Sketch on my Arduino Uno:
const boolean verbose = true;
void debug(const char *s){
if(verbose){
char buf[8 + sizeof(s)] = "[DEBUG] ";
strcat(buf, s);
...
2
votes
4
answers
2k
views
How to get elapsed seconds since Jan 1, 1970?
I am building a time-critical system using Arduino. Is there any way to get the elapsed seconds like time.h of C in Arduino? I tried time(NULL) but it returns 0. Then moved forward to use now() in ...
8
votes
6
answers
19k
views
how fast does loop() run in Arduino
Hi I am using Arduino Nano to gamify my experience on Unity3D. I know that Update() in Unity3D runs every frame per second but I because I'm not an electronics guy I don't know how loop() function ...
3
votes
2
answers
756
views
Millisecond timestamp (13 digits) in Arduino
How can I store a 13 digits int in Arduino?
For example, current timestamp is:
1500666822235
An uint32_t can only hold 10 digits max.
64 bits integer does not seem to be supported on RFduino.
0
votes
1
answer
731
views
MIDIUSB - Why is the command put twice?
Consider this function:
void noteOn(uint8_t pitch) {
midiEventPacket_t noteOn = {0x09, 0x90 | 9, pitch, 127};
MidiUSB.sendMIDI(noteOn);
}
midiEventPacket_t is defined as:
typedef struct
{
...
1
vote
1
answer
24k
views
Global variables with C++ in multiple files
I'm not a C++ programmer (but I have used regular C code for implementing low-level machine language equivalent SW for some time), and after trying to modify an existing cC+ program to do what I need (...
0
votes
1
answer
200
views
Avoid overflowing of counter
I have a global uint32_t that keep tracks of used Bytes:
uint32_t usedBytes;
int bytesWritten;
byteWritten = myFile.print(data, FILE_WRITE);
if (byteWritten > 0) {
usedBytes += bytesWritten;
}
...
0
votes
1
answer
1k
views
HMC5883L not working in continuous mode!
I'm just starting with the HMC5883L, I'm writing my code with C and also my own I2C library.
I noticed that the values on the Arduino IDE's serial monitor are constant.
Then I developed a function ...
1
vote
1
answer
393
views
Cannot obtain reading from meter (Modbus)
I have a system in which I am taking readings from a meter and processing it through an Arduino Nano. My code looks as follows:
#include <SoftwareSerial.h>
#define SerialControl 7
#define ...