Questions tagged [programming]

The process of designing and writing source code as part of a program (or sketch) for Arduino. For questions about uploading code to an Arduino board, use the [uploading] tag instead.

Filter by
Sorted by
Tagged with
2
votes
1answer
106 views

My motor driver gets stuck in either high or low with a certain speed super randomly. Motor output stops going based on accelerometer input

Running a DC motor(6.5A max input), motor driver (MD10C 7Amp peak output), and arduino Mega. Basically, I am creating a stabilized object based on the accelerometer's input. It works great but all of ...
4
votes
1answer
158 views

why is “if” slow?

I am new to the Arduino world and I hope I can find a solution here. The code below functionally works ok. The problem I have is, at line 45 I've inserted an if statement to change dac_value. It is ...
0
votes
1answer
38 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
0answers
23 views

Getting atsam3x8e (Arduino Due) to work

I decided to make a pcb based on the atsam3x8e (microcontroller used in Arduino Due). For the design I copied most of the layout that I found on this site and looked at the official Arduino Due ...
1
vote
1answer
71 views

Understanding Debounce code

I don't understand the following Debounce code. (The complete code is at the bottom.) From what I understand, when the pin reads something, we wait at least 50 milliseconds before performing anything. ...
0
votes
2answers
81 views

Is there a way to get about a 10ns Timer resolution from an AVR CPU?

I have an 8Mhz ATM32u4 that is able to read external pulse inputs at 125ns ticks using InputCapture3 (PC7) on its 16-bit timer. Is there a magical way (bitbanging?) to get around 10ns tick resolution ...
2
votes
1answer
78 views

Branchless programing on arduino?

So I've been looking into branchless programming to speed up code and I'm curious as to how exactly Arduino (or rather atmega328) actually reads machine instructions. Does it have a memory cache or ...
1
vote
0answers
49 views

avrdude not in sync

So this uno was working before, now i can't upload anything, can't even burn the bootloader. Using another arduino as isp does not work. It always says avrdude: stk500_recv(): programmer is not ...
1
vote
1answer
78 views

Cannot successfully implement singleton

I have spent the better part of today trying to figure out why I can't get this to work... I have this project where, because of previous design considerations, have implemented a singleton class that ...
3
votes
3answers
163 views

Programming Arduino Uno R3 to trigger a relay once every 24 hours

I programmed Arduino UNO R3 to trigger a relay once every 24 hours from the moment it is powered on I calculated milliseconds and used the function delay() 24 hours * 60 minutes each hour * 60 second ...
2
votes
1answer
64 views

Static ip for esp8266 based on gateway

I'm new to Arduino programming. I want to make my esp8266 get static IP based on gateway. I mean if gateway is 192.168.0.1 then it should get 192.168.0.15 as static IP. And if gateway is 192.168.1.1 ...
1
vote
0answers
52 views

SG 90 servos randomly spinning

I started one project where i need 4 servos to control 4 grabbers jaws. i use STM32F103C8T6 with arduino IDE for programming it. The motor TZT Micro Servo 9g SG 90. First, I was playing with stepper ...
2
votes
4answers
868 views

Arduino Object Oriented Programming

Can anyone send me a link tutorial about Arduino Object Oriented Programming? I want to learn Arduino, I am just a beginner.
1
vote
2answers
95 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 ...
1
vote
2answers
107 views

Counter program

I'm an absolute beginner, and lately I had some problem with this program I was trying to do. Basically I wanted with the Arduino to count 3 pulses from an oscillator and store the time of these 3 ...
0
votes
3answers
60 views

What's the most direct way to assign Serial.read() bytes to an array?

I'm trying to send NMEA 0183 sentences through LoRa. Every dinstict NMEA message looks like several char arrays (sentences) followed by '\n'. In the below picture we see one NMEA distinct message: ...
2
votes
1answer
42 views

WebSocket Server for MKR1000

I was looking for a websocket server for my MKR100 but nothing I found looks it works. I tried all the libraries that come with arduino but half of those doesn't compile on MKR1000 and those that did ...
-1
votes
1answer
47 views

Sending data struct with 2 int fields from Arduino to Raspberry via NRF24L01

I'm trying to do wireless thermometer on max31865 arduino and nrf24l01 but I'm having problem sending whole data struct I can send int or char arrays but when I try to send whole struct I got output ...
1
vote
0answers
21 views

Arduino and ZMPT101B But Not Stable Sigma Output In 7segment Display(TM1637) using filter library

#include <Arduino.h> #include <math.h> //TRUE RMS START #include <Filters.h> //Easy library to do the calculations #include <TM1637Display.h> float testFrequency = 100; ...
1
vote
2answers
69 views

How to properly put a u8g2 handle in a class

I'm trying to create a small battery powered alarm clock using an Arduino MKRZero and a generic SH1106-controlled, 128x64 pixel oled. I started out just dumping all code into a single file named Clock....
1
vote
2answers
114 views

Detecting an incoming 7.875 kHz pulse to use as trigger

I have written a code that detects an incoming pulse (square) of 7.875 kHz to trigger the output High for the entire duration of pulse, and trigger the output low if the pulse is off or not detected. ...
1
vote
1answer
45 views

More effecient datalogging code

Background: I am using a Teensy 3.6 to data log over a dozen sensors. I am printing to Serial1 for local Serial access, Serial3 for remote access (via xbee, same data is on Serial1 as on Serail3, just ...
1
vote
1answer
35 views

Please , explain about MAX30100 using for Arduino to read ADC in format (0-1023) [closed]

can anyone help me..? I am using MAX30100 with arduino, and my expectation is i can to process the ADC as usual (0-1023), but I do not understand the signal processing. Has anyone used the MAX30100 ...
1
vote
1answer
42 views

Why is their need of response time needed in esp8266 AT commands?

I am writing an AT commands firmware for esp8266 via connecting it to atmega2560. Now the question is how will I come to know the response time for AT commands for writing its firmware to read the ...
1
vote
1answer
54 views

inconsistent digital output on simple code

so im new on arduino coding, and i made this code, where i input from serial monitor and then use it as a command for digital write. the problem is, sometimes the code work perfectly but then when i ...
0
votes
0answers
119 views

Digispark Atinny85 not recognized (bootloader problem)

I recently bought the Attiny85 (picture below) I managed to install it correctly following the official guides, never that a problem. Drivers are installed correctly, and I used the Arduino IDE to ...
1
vote
2answers
230 views

What exactly does the return type do in a function?

something I've never understood and still don't is, what does the return type do specifically? Everyone in tutorials just say that void returns nothing and int returns int, etc. But what does that ...
0
votes
0answers
24 views

Arduino Due Master Programming

I am newbie. In my application Arduino Due is configured as Master and Arduino Uno as Slave. I need to transfer 24-bit Hexadecimal data of about 79-registers to slave device. At the slave end in ...
0
votes
1answer
62 views

If the code used for Arduino can be embedded into a permanent , callable memory, is there a way to create an OS for Arduino that runs on call?

This thought came into my mind on thinking about smartwatches. Although those I saw on YouTube are really good, they don't seem to provide a real experience of a real smartwatch - one that has an OS ...
0
votes
1answer
82 views

How can I assign the value of a char array to a uint8_t array?

I have a char array variable that has a value. I need to send this value through LoRa. The library I use for the LoRa implementation accepts an array of uint8_t. How can I pass the value of a char[] ...
0
votes
0answers
424 views

esp8266 Arduino error : esptool.FatalError: Failed to write compressed data to flash after seq 1 (result was C100)

i have simple circuit for controlling the dc motor by bjt BC869 like this: and this code: /* ESP8266 Blink by Simon Peter Blink the blue LED on the ESP-01 module This example code is in the ...
0
votes
1answer
62 views

How do I generate a graph from Arduino sensor data?

I used a DHT 11 sensor with an Arduino Uno to measure temperature and humidity. I used the following code to print the temperature and relative humidity in Serial Monitor. dht DHT; #define DHT11_PIN ...
1
vote
2answers
134 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
1answer
69 views

Run a part of a code only 4 second

I have two different programs written for my Arduino. One control the rockets thrust vector. The other one is for parachute. I need to first run rotationmatrices() for a 4 second and then parachute. ...
1
vote
1answer
49 views

I want to program multiple arduino at once

I am aware that using a USB Hub you can attach multiple arduino to one computer and either upload code one by one or use bash script to upload code on all arduinos together. But you can attach only as ...
0
votes
0answers
209 views

Program Nano Every using UPDI port

I have and Arduino Nano and an Arduino Nano Every. I'm doing some experiments and trying to program the Nano Every from the Nano, using the UPDI port. I'm using tutorials like this one that does the ...
0
votes
0answers
30 views

Arduino glitches and makes 240 < 7 and -240 > 7

I'm experimenting with the joystick and the MAX7219 module (8x8 LED display) and i made this program: #include "LedControl.h" LedControl lc=LedControl(11,13,10,1); int Xo = 36; int Yo = 34;...
0
votes
2answers
98 views

How to convert RGB values to Intensity

I made an arduino color sensor with tcs3200 and arduino uno. I have coded the arduino to find the RGB values when I place the color paper below the sensor. How can I derive the intensity using the RGB ...
0
votes
1answer
49 views

Why is there a need of use delay() after using Serial.flush() in the program

This code is a part of a long code for understanding serial communication and the functions related to it. char buffer[18]; int red, green, blue; int RedPin = 11; int GreenPin = 10; int BluePin = 9; ...
0
votes
0answers
173 views

Can the Arduino Pro (Portenta H7) communicate between threads?

I have an application that runs a stepper motor from an Arduino board. This requires use of the delayMicroseconds(int us) to control the speed at which the motor turns. For this reason, all code ...
0
votes
0answers
51 views

Is there a way for an Arduino to flash another one without a computer?

I am going to create a game console. The games will be in an SD card and an Arduino (or an Atmega chip) will read a hex file's contents to RAM and will flash it to another one. Something like this but ...
5
votes
4answers
2k views

What are the traditional ways to optimize program memory usage?

While doing big projects using Arduino boards (Uno, Atmega328P MCU). I used to get warnings like this Sketch uses 13764 bytes (44%) of program storage space. Maximum is 30720 bytes. Global variables ...
0
votes
0answers
22 views

Defining a function before a class makes the class undefined? (MWE provided) [duplicate]

In ArduinoIDE 1.8.12 this code will Verify successfully: struct myINT { int i; }; myINT makeINT() { return myINT{5}; } void setup() {} void loop() {} ...no surprise, right? However this won't: ...
-1
votes
1answer
50 views

How to get data out of loop?

hi i wrote a code(i modified it actually, please forgive me, im in a mess please help me if you can) for my esp8266 to serial communicate with at tiny 85 ,it will monitor switch state and publish ...
0
votes
1answer
64 views

Getting enum name from enum instance [closed]

Hello Arduino Stack Exchange, I have an an enum instance called state: enum States { SLEEP, AWAKE, CRAZY } state; States state = SLEEP; I would like to convert the value of state to a String so ...
1
vote
2answers
82 views

Fast random booleans

I am looking for a way of generating booleans rapidly. For booleans, one usually uses random(0,2); but in my case I need about 250 booleans and calling random every time is slow. So I thought about ...
0
votes
2answers
42 views

what is good practice around initializing variables

Should vars be initialed when declared or in setup fuction? Safe to assume compiler will initialze? Boolean x; --- init to true/false here? Void setup() . . --- or init here? . Void ...
0
votes
0answers
38 views

Construct char arrays within function

I'm pretty new to C++ / Arduino code, please bear with me. Following code currently gives me a Exception (28): epc1=0x40201287 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000. I ...
0
votes
1answer
54 views

Using RX TX pin

Can i use pin RX TX on Arduino Uno as reguler pin ? . For input and output pin , because two digital pin on my board doesn’t work . Thank’s
0
votes
1answer
459 views

Attiny85 microcontroller programming without arduino

I have decided to make a simple project so thinked about arduino but that seems very worthy so i decided to use attiny85 ic for my project,but i don't have arduino or avr to program it. Is there any ...

1
2
3 4 5
31