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
19
votes
5answers
7k views

How much can I recurse? How much can I recurse? How much ca!@#QFSD@$RFW

The Arduino Uno board has limited RAM which means it has a limited call stack available. Sometimes, recursion is the only quick option to implement a certain algorithm. So, given that the call stack ...
12
votes
3answers
47k views

Functions with string parameters

Inside my main loop there is this string: String string1; I have a function that will take string1 as parameter, and use it to send this string as SMS. sendSMS(string1); This is the sendSMS() ...
10
votes
3answers
92k views

Why is my LCD 16*2 is not displaying any characters, although all the wiring is correct?

Recently I have linked up a typical 16*2 LCD (Liquid Crystal Display) display to my Arduino Uno and have linked all the pins up. Here is my connection:(LCD pin first) 1=GND, 2=+5v, 4=11, 6=12, 11=5, ...
8
votes
2answers
4k views

OOP vs Inline with Arduino

I have been programming for quite a while now but I am new to Arduino and AVR Programming. The main question I have about programming these Micro-controllers is are there major differences in ...
6
votes
1answer
3k views

strange behaviour of dtostrf()

I'm trying to program a little bit in Arduino, but I'm stuck with probably something trivial. This is what I have: char ang[3], lat[9]; dtostrf(GPS.angle, 3, 0, ang); dtostrf(GPS.latitude, 9,5, ...
4
votes
2answers
5k views

Simple URL decoding

How can I do a readable, small, smart and good URL decoder in Arduino? Now I'm using this code: String GetRidOfurlCharacters(String urlChars) { urlChars.replace("%0D%0A", String('\n')); ...
3
votes
1answer
100 views

Project structure to build for PC and Arduino

Recently I have started developing for Arduino Uno. I have 10 years experience in software development (C#, Delphi), but not much with C/C++. Compiling the Arduino sketches seems a little slow, and ...
3
votes
1answer
6k views

>> << and -> Syntax in arduino

I was trying to follow this tutorial and came across >>. What exactly does this do?
3
votes
3answers
6k views

how can I upload a hex file to an arduino uno?

I have a Rostock Max 3d with an Arduino Uno as the controller. The OEM has a firmware version I would like to upload, but it is in the hex file format. I have looked all over the Arduino IDE, but ...
1
vote
2answers
207 views

How can I reduce the redundancy of this code, so one function can perform the task of printing on Serial and Softserial?

void Multi_print (String str) { Serial.print(str); mySerial.print(str); } void Multi_println (String str) { Serial.println(str); mySerial.println(str); } void Multi_parse_int (int value) { ...
1
vote
1answer
10k views

Send JSON via POST on SIM900 shield with AT commands

I'm trying to send a JSON POST in SIM900 shield with AT commands. After I call the AT+HTTPACTION=1 command, it returns a 601 error: +HTTPACTION:1,601,0. I saw here that the error was 601 Network ...
1
vote
1answer
11k views

How to use strtok() and strstr() with arduino?

Can anyone explain how things like strtok() and strstr() can be used to provide a numeric value for a substring location position within the mainstring array. I've tried to understand from the C++ ...
1
vote
2answers
4k views

Obstacle avoidance algorithm

TARGET The task I have taken as a challenge is to make a GPS-guided robot incorporated with features like Arduino for programming, ultrasonic sensors for obstacle avoidance and a GPS module to ...
1
vote
1answer
227 views

Capacitive “keys” press event registration issues

Seeing as this is my first post I would like to thank everyone ahead who take their time to delve into my whimsical code, whoever you may be, be merciful ;) For one of my uni projects, I would like ...
1
vote
2answers
2k views

How to set address for using more than MPU9250 [duplicate]

I am trying to build a project that contains more than one MPU 9250, until now I'm still confused to MPU9250. If I were going to that, does anybody here know how to set addresses to each of the MPU's ...
1
vote
2answers
463 views

Arduino Prototype on Breadboard: “avrdude: stk500_recv(): programmer is not responding” [duplicate]

I have created an arduino prototype using the exact instructions found on this page: https://www.arduino.cc/en/Main/Standalone However, when I plug in the micro USB power supply and try to upload a ...
0
votes
1answer
55 views

someVariable = { somethingThatLooksLikeAFunction }; possible? [closed]

Wasn't sure how to title this question... I was curious whether the title example is possible somehow, and are there any good tricks to using it? I have been using something similar quite a lot: ...
0
votes
1answer
58 views

Why are begin() functions needed to initialize hardware (if they are)?

I'm writing a program for an ATmega microcontroller using the Arduino framework. While implementing an hardware-related class (one to manage LEDs), I put some hardware initialization code such as ...
0
votes
1answer
797 views

Arduino Due: ADC gain adjustment problem

I want to increase gain of the ADC channel. To achieve this I'm using adc_set_channel_input_gain function from adc.h. Here is the entire sketch: const byte aPin = A6; void setup() { ...
-1
votes
3answers
303 views

Controlling Arduino from Raspberry Pi

I am trying to control an Arduino Leonardo R3 to run some code when "triggered" from a Raspberry Pi. This would be in a loop so that it can be run multiple times. I have set up the Raspberry Pi and ...
-1
votes
2answers
491 views

What would be the code for using Arduino UNO to alert by sound or LED when it detects a certain position through GPS?

I am in grade 6. I have a very nice pet dog in my house but it often enters Mom's kitchen to spoil all the foods. So I am thinking of a device to attach with him which can locate its position. But I ...
14
votes
5answers
6k views

Programming options other than C++

Can I program my Arduino using any programming language other than C++? If so, which programming languages? What software would I need for compiling and loading my code onto the Arduino?
6
votes
4answers
4k views

Multithreading with Arduino

Well I've just started learning the concept of multithreading with C++ and immediately a bunch of questions came to mind about the possibility of using multithreading with microcontrollers in general ...
5
votes
4answers
16k views

How to avoid blocking while loop reading Serial?

I am currently playing with a MindWave Mobile headset. I am parsing bluetooth data received from a connected BlueSMIRF Silver. The code I started from is a sample from the MindWave wiki and it works ...
4
votes
1answer
3k views

Useless box wiring and code

just want to give a back story first. So i saw this video on youtube about the useless box, and i thought that it would make a great gift for my 7 year old. So i went out and bought everything that ...
3
votes
2answers
1k views

Arduino cluster functionality - feasibility advice for arduinos to communicate using variable-length long strings?

My apologies. This is my first time on this site and I wasn't even aware that it wasn't some sort of discussion forum until receiving the automated response message to my already submitted vague and ...
3
votes
2answers
3k views

HC-05 bluetooth module not accepting AT commands

I have been attempting to program my HC-05 ZS-040 Bluetooth module for quite some time, and I cannot get the AT commands to return any values. I have searched google for quite some time, and I none of ...
3
votes
2answers
3k views

Concatenation of non constant character array with a string

I have an Arduino Duemilanove. I read this page on string concatenation. Yet, it didn't include my case. I have a non constant character array, that later gets a value. char clat[11]; dtostrf(gps....
2
votes
1answer
63 views

TFMini Sensors with Arduino

I have three TFMini sensors I need all of them to detect. I only got one to work , pins 4,5 . My info in coding is basic . I really appreciate your help . Thanks in advance. I think the problem is ...
2
votes
4answers
815 views

Why doesn't this debounce function work?

Edit 2 I made a function that works, but I'm still confused about just one thing... I'm very confused about how variables work in C++. In this program... boolean debounce(void) { static ...
2
votes
4answers
7k views

Interrupt fires multiple times

I have a Photo Interrupter which I am using to count the RPM of a motor. I am incrementing an integer to show the amount of interrupts there have been. The issue is that there can be several ...
2
votes
1answer
40k views

Combining code for multiple sensors in one program

I need to operate 2 different sensors (gas and temp) simultaneously. I have managed to run each one of them separately and I don't know how to manipulate the code so they could work together. My ...
2
votes
2answers
3k views

Arduino Variable Data Type?

Is there a variable data type available for Arduino? I have a class that should have a member that will differ in data type, in the past I have used the "variable" keyword in c++ but when I tried to ...
2
votes
3answers
1k views

Proper way to run functions in loop

I am having a problem getting my functions to run properly from the loop. I am building a model railroad crossing gate and need to run the 4 processes once the sensor signals the train entering the ...
1
vote
1answer
901 views

Servo motors won't work with motor controller

I have a motor controller controlling two motors, which works perfectly fine when I comment out the two servos in the below code. These two servos are not connected to the motor controller but simply ...
1
vote
0answers
62 views

Function parameter of type int not working as expected

I am attempting to write a small sketch with the Arduino IDE (1.8.10) to set the colour of an RGB LED, however my function for setting the colour of the LED is behaving strangely. Here is the full ...
1
vote
1answer
815 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 "...
1
vote
0answers
75 views

Arduino mega PinChangeInterrupt with 16 bit timer

With reference to this question ::I have written a program by using 16-bit timer, The program is as follows . volatile uint32_t ovfCount = 0; struct Pulse { uint32_t last_toggle; uint32_t width; ...
1
vote
1answer
65 views

Issue using Arduino Mega Timer2 with PinChange Interrupt

I was working on a program to measure the pulse width , for that I thought of using Timer 2 in Arduino mega along with pin change interrupt, The program I have written is as follows volatile float ...
1
vote
1answer
3k views

Nothng Written to Serial when using sprintf

I'm using sprintf to use a format specifier myTemplate with some strings. The result will then be written to Serial. Although the sketch compiles fine, it does not write any thing to the serial, ...
1
vote
2answers
1k views

Modbus Protocol Compile Error

I have Code for Mod bus Library as below. I have Gone through lots of forum. How to assign device ID, slave address, length using below library function: #include <SimpleModbusSlave.h> #define ...
1
vote
1answer
85 views

Bluetooth module(HC 05) issues

I am trying to make a Bluetooth controlled 4WD robot. i was following a tutorial i found online (https://howtomechatronics.com/tutorials/arduino/arduino-robot-car-wireless-control-using-hc-05-...
1
vote
2answers
2k views

Arduino analog joystick

I'm planning to make a handbrake for my racing simulator (Assetto Corsa) and I wanted to know how can I transform arduino into a joystick so the game can read the analog input? Thanks in advance, and ...
1
vote
1answer
109 views

Arduino Yun doesn't link any library

I'm writing code for a project with Arduino Yun. My project is quite simple: it takes a picture with a webcam and saves it in a PNG or JPEG file format. I've already installed the uvc driver for ...
1
vote
2answers
1k views

Aduino 7 segment dice project

I am struggling with the code that I should write for my project. I finished my breadboard but I have never learnt programming before so I cannot write the program for the dice. My project is to make ...
1
vote
0answers
848 views

ESP8266 to send data to thingspeak while doing unblocked read on Serial.readString()

I have a requirement to get RFID data on Arduido UNO and send it to ESP8266 to be sent to ThingSpeak via the Wifi module. However, ESP8266 is also programmed to send Temperature and humidity data to ...
1
vote
1answer
3k views

How can I programming detect that a Bulb/LED is ON/OFF or a circuit is working as expected using Arduino?

I've created a circuit to turn on bulb using GSM module and Arduino. I want a mechanism(or programming) to know whether the bulb is on or off or fused. I've tried taking the input from the pins. But ...
1
vote
2answers
98 views

Getting started [closed]

so I am not a newbie to computers or programming. I regularly program in C# and Java, know quite a bit about computer hardware and operating systems. But I am bored of writing stupid calculators or ...
1
vote
0answers
55 views

Controlling Arduino from Raspberry Pi [duplicate]

I am trying to simply send a digital output from the Raspberry Pi to trigger some code on an Arduino. I have setup the Pi with the digital output working fine (tested using LED) however, I cant seem ...
1
vote
2answers
56 views

Getting different results from function. How to retrieve values correctly?

Trying to implement PI controller in function. Already worked for one controller. However, for more than one controller, the results are shifting. Suppose to get same values in the following code. ...