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
1
vote
2answers
115 views

How to actually concatenate two Strings?

I'm using the SPISlave library, and I have the following code snippet: String arg; SPISlave.onData([arg](uint8_t *data, size_t len) { data[len] = 0; arg += String((char *)data); // ... } The ...
0
votes
1answer
35 views

Why do I see error in this code

NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE); AF_DCMotor motor1(1, MOTOR12_1KHZ); AF_DCMotor motor2(2, MOTOR12_1KHZ); AF_DCMotor motor3(3, MOTOR34_1KHZ); AF_DCMotor motor4(4, MOTOR34_1KHZ); ...
0
votes
1answer
69 views

How to scale a bitmap (uint8_t array) in Arduino?

So I have a project where I send text to an Arduino, which is then printed out as a QR code on a thermal printer that can take a bitmap image with a given width and height. Is there a way I can "...
0
votes
1answer
23 views

ESPAsyncWebServer how do you escape the % character?

% characters are used for template processing but I want it to just send the % through. How do you tell it to do that?
0
votes
1answer
47 views

Forward kinematics of a differential drive robot

I've been braking my head over this for the past few days and can't make it work.. So, I have a small robot with a rotary encoder on each wheel and i want to track its position (in x and y) on a flat ...
0
votes
1answer
37 views

Waking Arduino from sleep with an ultrasonic sensor

I have a parking guide using an ultrasonic sensor (HC-SR04), based on the instructions here. I'm trying to modify the code so that the Arduino goes to sleep after a certain period of inactivity (say, ...
0
votes
0answers
34 views

Can I determine if I have been pinged?

I have a project using a Wemos D1 Mini. Is there a way for the sketch running on the Wemos to know when it's been pinged?
0
votes
0answers
31 views

Rocket deploy system

I found a code from Astronomica Messier that allows to activate a servo from a Gyroscope MPU 6050 change in direction. I followed the wiring and uploading correctly. The thing is that the MPU is ...
0
votes
1answer
53 views

Error: “'lcd' does not name a type” using LiquidCrystal library

I'm following an online Arduino tutorial/course and trying to make a simple moving character on an LCD screen, but for some reason I get the following error: "error: 'lcd' does not name a type". I'm ...
1
vote
1answer
61 views

Merge two 8 bit arrays to one 16 bit array

I am an absolute newbie to Arduino and C++ and try to go through some tutorials to gain a minimal insight. However I stuck already at some tiny Points. What I want to do? Merge two 8 bit integer ...
0
votes
0answers
31 views

My alterate flashing LED program is not working

I am trying to program my Arduino UNO ATMega 328p in assembler to implement a flashing pattern with two LEDs. When one LED is off, the other must be on. I have made a program but it is showing errors ...
0
votes
1answer
34 views

I´m trying to make a kind of videogame with Arduino UNO

it´s a school project, but I'm having some problems to create a menu selection. In the LCD, all the character are overwriting, I'm a beginer, so i dont have any idea of what i was doing wrong (ps.: ...
0
votes
1answer
37 views

led chaser fill color effect

Please help. I am learning a lot about Arduino. Most all in lightning. I am a newbie. I play with nano and LED ws2812 and use fastled library. What ask is to make effect like fill effect. For ...
0
votes
1answer
38 views

Non-blocking incrementation with single button pressure

I am looking for a way to increment a variable by one each time a button is pressed. Current approach is the following : if (redButton.isPressed()) { a++; delay(100); } ...
0
votes
1answer
76 views

Programming the ATMega328P without Arduino board always returns the error: avrdude: stk500_recv(): programmer is not responding

I have a microcontroller: ATMega328P. I don't have any Arduino Uno board. I want to program the ATMega328P using my FTDI programmer. But when I try to program the ATMega328P without Arduino board I ...
0
votes
1answer
58 views

Two Arduino Control a LCD Display

I´m building a system that has two arduinos (like the image on the botton) linked via ICSP. The "Programer" programs the second one, called "Worker"( with a .hex file in the SD card of the Programer)....
1
vote
1answer
66 views

Pro Micro ATMEGA32U4 unable to upload

I have a simple flashing led program that I want to upload on my pro micro (see image) but it doesnt work (see image: no port available, Couldn't find a Board on the selected port. Check that you have ...
2
votes
1answer
141 views

How to send UDP data packet between two access point?

I am new to arduino programming and nodeMcu boards.I have two ESP8266 bards as access points and one board get some data form WiFi stations and resend that data to other access point. but the problem ...
0
votes
1answer
35 views

Attempting to monitor serial output for a string to trigger function, apparently matching string is output but the function doesn't trigger

I'm working on my second Arduino project, and am somewhat stuck. I'm running a PIR module from my Arduino Uno with the following sketch: /* * PIR Sensor test */ int pirPin = 6; int ...
0
votes
0answers
42 views

Effective Controlling of Continous Servo Motor

I have difficulty in controlling a MG995 continuous motor. For I know I can control the speed of the motor as writing servo1.write(p) , where the value of p changes the speed of the motor. When the ...
0
votes
0answers
30 views

How to re-send UDP data packet to a esp8266 board? [duplicate]

I have several connected esp8266 boards. Lower level client boards connect to middle level esp8266 board and middle level board connects to the top level Esp8266 board (AP).When a client sends UDP ...
0
votes
2answers
74 views

Is My Motor Shield Broken?

So I am trying to work on a mini battle bot project. However, it has been a while since I have worked with my Arduino electronics. So I am going through and learning how to do each thing before ...
1
vote
3answers
104 views

DC motor does not work using PWN or Digital pins

I have connected pin 3 to a DC motor and using analogWrite and DigitalWrite to try making it start. However, nothing happens. If I try to move the pin from pin 3 to 5V or 3.3V the motor starts. Q: ...
-2
votes
2answers
107 views

Timing 12 relays

I need a simple code to turn on 12 outputs one after another 2 seconds apart. A pushbutton will initiate this and the outputs will stay on for 3 minutes at which time all outputs will turn off ...
0
votes
2answers
35 views

How to set cables to connect Cp2102 to Pro Mini?

How to connect the cables in order to program the pro mini with the CP2102 usb interface ? The TX RX and GND is easy, but I am not sure about the RST, DTR, DST, etc I attached the images of both. ...
0
votes
1answer
76 views

Pro Micro with Atmega32U4 - reset - reprogramming

i am a new user on arduino card. i have a question about "Pro Micro with Atmega32U4". - is this product programmable several times ? and the third pin (RST) - (Reset). so, does reset mean it erases ...
1
vote
2answers
85 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 ...
-2
votes
2answers
66 views

How to read distance of passing object?

Ok, guys this is my first post and I am new to Arduino but somewhat familiar with programming so I hope you guys can assist me. If any of this is confusing, I apologize in advance! :) I want to be ...
0
votes
2answers
143 views

Optimizing code to use less Flash Memory and SRAM

I'm trying to reduce my sketch size and managed to reduce both SRAM and Flash memory. From: 1570 SRAM - 32144 Flash memory To: 644 SRAM - 19458 Flash memory This are what I've done so far: ✓ ...
1
vote
1answer
40 views

How to detect patterns in an FFT output?

I have an FFT output from a microphone and I want to detect a specific animal's howl from that (it howls in a characteristic frequency spectrum). Is there any way to implement a pattern recognition ...
0
votes
1answer
51 views

Modular Coding - What types of code portions to convert into library files? Rationale and methods?

I'm working on documentation and combining 2 pieces of code for testing parts of a larger project. I'm supposed to comment and make the code very clear to people who will use it later and make sure ...
2
votes
2answers
106 views

DS18B20 with only OneWire library

Peter Scargill found a way to use DS18B20 temperature sensor without any library and just using OneWire library, and it's amazing how blazing fast it is! (it's an old article from 2013) #include <...
0
votes
0answers
18 views

How to adapt this code using a DF Mini Player and interrupts for the ATTiny85?

So I programmed my Arduino Mega 2560 to play certain sound effects from a DF Mini Player that I have. I took the base code that I modified from online so some fo the names might seem odd. Currently, ...
0
votes
1answer
41 views

Do we have an alternative for millis() function?

This is actually a follow up question to this question, so basically I'm using DS18B20 temperature sensor which requires Onewire.h library that interrupts millis() function. Luckily i have a DS3231 ...
-1
votes
2answers
55 views

RTC timer set point problem

This is the timer part of my code: int onHourONE = 11; int onMinuteONE = 00; int offHourONE = 23; int offMinuteONE = 00; byte PWMstatus = 0; void setup{} void loop{ if ((now.hour() >= ...
-1
votes
1answer
71 views

Refactoring bad design?

Could someone help me how to refactor old very complex code ? Original used just setup and everything else was in single ISR. But as it was bigger and bigger, code is quite slow and quite random ...
1
vote
1answer
112 views

How to NOT repeat a piece of code again and again?

I have a VERY long code: Sketch uses 30468 bytes (92%) of program storage space. Maximum is 32768 bytes. I've been trying to reduce it's size so i can write more code, one of my main part of ...
0
votes
0answers
82 views

Having problem in coding Arduino Uno

I'm making a timer program which takes the Time Duration as input from the user by two button switches (one for 'up' and one for 'down'), and after pressing an another button switch ('start'), the ...
0
votes
2answers
356 views

Using the YS-IRTM with an Arduino Uno

Picked up a YS-IRTM IR Transmitter/Receiver module to do some testing for a project. There's not a lot of details on it but eventually came across two very important sources: Translated Module ...
0
votes
1answer
30 views

Using case statement with IR emitter reciever

I am trying to use two "infrared obstacle avoidance modules" to work with the following sketch. From all my research, I believe, a case statement is my best option because, (I understand) the sketch ...
0
votes
0answers
24 views

UV sensor help!

I am creating a uv sensor. The sensor detects a certain amount of UV light and turns on the respective light (eg uv of 1-3 turns on a blue light). However I am getting an error: "expected primary-...
0
votes
0answers
30 views

Accel Multi Stepper - Array for timelapse operation

I am trying to run 2 cameras for timelapse. I can do this with a single stepper: void doSteps(long steps) { calcSpeedStepper(); digitalWrite(sleepPIN, HIGH); stepper1.setCurrentPosition(0); ...
-1
votes
1answer
35 views

Error: exit status 1 stray '#' in program [closed]

I got this error: exit status 1 stray '#' in program How can I remove this error..? int keys = {1,2,3,A,4,5,6,B,7,8,9,C,*,0,#,D};
1
vote
3answers
241 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;...
3
votes
1answer
45 views

writting to buffer from serial input

Can some one explain this behaviour please, i have the following code byte buffer[512]; byte block; byte len; Serial.setTimeout(60000L) ; // wait until 20 seconds for input from serial ...
-1
votes
1answer
36 views

expected unidentified id before 'if" [closed]

#include <iostream> using namespace std; char board[3][3]={{'1','2','3'},{'4','5','6'},{'7','8','9'}}; char turn='X'; int draw=0; int row,column; void display_board() { system("cls"); ...
0
votes
1answer
56 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 ...
0
votes
1answer
84 views

PWM delay without blocking the code

I want my LED to turn on gradually without using the delay() function and blocking the code. Here's the code i came up with: int led_pin = 6; unsigned long millisTimer = 0; int PWMdelay = 5000; int ...
1
vote
3answers
102 views

class enum was not declared in this scope

I am programming an Arduino. In the same .ino file as setup() and loop() I have defined the following: void setup() { // setup code } enum class CYCLE { TypeA, TypeB }; String cycleToString (...
0
votes
0answers
20 views

HC-05 Bluetooth AT Mode

I know that I need to pull pin #34 high on the HC-05 "chip" (AKA PIO11) while powering ON the chip in order to put it into AT mode. Can I leave that pin high while programming, or does it need to go ...