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
1answer
52 views

ESP8266 Webserver ESP8266WebServer variable html page (not as one const char)

The aim is to display a non-static html page depending on some variable condition. The code I created hast the problem, that the esp8266 is ressetting in the moment I request the page. const char ...
1
vote
1answer
19 views

ESP8266 Webserver ESP8266WebServer move Handler-Function in separate .h .c file

The plan is to create a bigger project and to split the ESP8266 webserver-code over several modules (.h .c files). The main problem is that the ESP8266WebServer server is not declared in the index.h ...
1
vote
1answer
44 views

How to use H3LIS331DL 3-Axis Linear Accelerometer with arduino to detect Harsh braking of vehicle

I am a newbie here, Recently I was working with H3LIS331DL 3-Axis Linear Accelerometer I²C Mini Module Here is code for the X, Y, Z-axis. #include <movingAvg.h> #include <...
0
votes
0answers
17 views

How i can separate integer number in 3 “houses”? Hundred, Ten and Unity [migrated]

I have, for example, a variable int number = 300; And i need modify "number" by "number", i wonder if i need separate in 3 variables for hundred, ten, unity or if there a method for divide that ...
3
votes
1answer
55 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 ...
0
votes
2answers
55 views

data classification with arduino

I want to classify my data from 3 sensors with arduino so that every time i enter the specific date or hour, or also it can be a period of time like 10 days ago, it shows me the exact data. In other ...
0
votes
1answer
23 views

Use JYETech 2.4 Inch LCD Display Screen Module with Arduino?

I have this JYETech 2.4 Inch LCD Display Screen Module that I would like to use for a project I have in mind, however, I'm not sure how to wire it up with my Arudino Mega. Here is the datasheet for ...
0
votes
1answer
25 views

ARDUINO flashing lights

I'm making a circuit with my Arduino so that when it receives a '1' or '2' or 'a' it turns on or off the LEDS. But I wanted the lights to flash and do not know how to do loops in loops or if that's ...
0
votes
1answer
34 views

I need some help getting data from a rangefinder

I have wired up my range finder (CJVL53L0XV2) to a breadboard for testing and have run the arduino example code for the rangefinder. The rangefinder works, but I do not know how to take the distance ...
0
votes
2answers
37 views

How do I segment Arduino program when line count is so large that code maintenance is difficult?

I'm looking for the Arduino/C++ equivalent of COBOL's 'copy' statement. I'm working on a program that is approaching 600 lines of code in the TopLevel.cpp source file. This is hard to manage ...
0
votes
0answers
28 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
0answers
52 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 ...
0
votes
2answers
49 views

Will an Arduino Uno be able to read 3x incremental encoders?

Encoders are quadrature 600ppr encoders with X2 counting. Therefore 1200 counts per revolution for each encoder. Is there an edge rate limit? I currently have one encoder hooked up using code with ...
0
votes
0answers
31 views

ARDUINO + SIM808 POST ERROR 400 BAD REQUEST

Please, I need help with debugging communications through a SIM808 Device I'm using alongside an Arduino Uno R3 as a prototype for a tracking device. The sketch is provided below. #include <...
0
votes
2answers
34 views

WS2812 Stair lighting - not all LEDS lighting up

I'm doing a Arduino based stair light project and have a little problem with the code. I have used Simon Jowett's code from the instructable website which after a couple of tweaks works perfect. Apart ...
0
votes
1answer
30 views

Is it possible to run two small motors off an Arduino and have the motors move separately based on a random number generator?

I am a 2nd year design engineering student working on a design project where we are tasked with automating the movement of a rainfall simulator. One of our design ideas consists of two small motors ...
0
votes
1answer
18 views

What kind of data type can be use store a binary bit-stream which is more than 64-bits?

I'm wondering if one needs to assign a bit-stream of 78 bits to a variable(later on to be processed), what datatype can be used? What is the max bit can be stored into a variable in C?
1
vote
1answer
43 views

How to split a binary data to form two split binary data?

I want to split a received binary data into two binary data. Take the following received binary data for instance: uint32_t data = 0xFFFF0001; In binary format it is: ...
0
votes
2answers
55 views

while(1) inside if conditional

if (!MDNS.begin("esp8266")) { Serial.println("Error setting up MDNS responder!"); while (1) { delay(1000); } } I know this will result in an infinite loop if the if conditional is ...
0
votes
2answers
38 views

How to use ATtiny pins that are usually 'reserved' for chip programming?

How to program an ATtiny45 to use the pins 1, 5, 6, 7 (i.e. PB5, PB0, PB1, PB2) as input or output? pinMode(5, OUTPUT); pinMode(0, OUTPUT); pinMode(1, INPUT); pinMode(2, INPUT); digitalWrite(5, HIGH);...
1
vote
1answer
28 views

cant figure out how to fix this compile error

evrything worked for a bit and changed to much to get it working again. dont really understand the error. [![C:\Users\bavob\AppData\Local\Temp\ccyfrkaL.ltrans0.ltrans.o: In function `loop': C:\Users\...
0
votes
2answers
44 views

Help with Stair Lighting using HC-SR04 sensor and WS2812 LED Strip

Excuse my naivete in this as I am very new to Arduino and the programming of. I am trying to put together a project for stair lighting triggered by a ultrasonic sensor at the bottom of the stairs and ...
0
votes
1answer
123 views

DS3231 + button to trigger light

please can someone help me with code, i want to have automatic trigger on specific hour, also i want to have button switch if needed, in my code i can press the button to trigger light relay, but my ...
0
votes
0answers
12 views

nodemcu nack error bh1750

I am trying to run a simple example of bh1750 on my nodemcu, code is #include <Wire.h> #include <BH1750.h> */ BH1750 lightMeter(0x23); void setup(){ Serial.begin(9600); Wire.begin(...
0
votes
1answer
36 views

Creating an array with the length coming from a library

When creating an array like in the sketch #include <Lib.h> int myArray[Lib::len]; void setup() {} void loop() {} the variable len must be an integer constant that is known at compile time. ...
0
votes
1answer
40 views

Error: invalid application of 'sizeof' to incomplete type 'int []' when trying to compute the size of an array in a library

I have created a library that contains an array. This is the .h file: class Lib { public: static int arr[]; }; And this is the .cpp file: #include "Lib.h" int Lib::arr[] = {0, 1, 2, 3}; ...
0
votes
1answer
28 views

Arduino - Extracting Multiple Strings from Serial Read

I am trying to write an Arduino code that reads a long string, example <11,22,33>, through the Serial Monitor and then stores the 11,22, and 33 into separate bins of a matrix array. So the user ...
0
votes
1answer
39 views

Help with arduino code

Thank you for seeing my post. I am trying to write a code that lets "A" displayed on row 1 and row 0 alternately on the LCD. starting from (0,1) then (1,0) then (2,1), then (3,0) etc.. when it ...
0
votes
1answer
33 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){ ...
0
votes
0answers
33 views

Arduino Due: Measuring the time between pulses

I have a 'pulse train' generated from a photo interrupter and slotted disc mounted on a rotating shaft. My goal is to measure the time between each rising edge. I have looked at the data sheet for ...
-1
votes
1answer
49 views

Program for counting days

I need a program to count days, from day 1 to day 21 for my project. I'm making an artificial incubator and I need to show the days on an LCD.
0
votes
2answers
132 views

Yet another basic and silly question about C++ strings

I made a sketch like this: void setup() { // put your setup code here, to run once: Serial.begin(9600); char str1[64] = "test with spaces"; char str2[32] = "test with spaces"; Serial....
1
vote
1answer
55 views

Can someone help me solve a loop question and a couple others for my program?

I am currently working on the elegoo uno r3 smart car kit that uses arduino. I have written some code and it works for the most part but I could use some help. I am trying to figure out what i need to ...
0
votes
1answer
44 views

Privacy of a program

I have created a algorithm and using arduino harware, and I don't want that users of my hardware could read or copy the Program so is there any security code or something that I could use. But I must ...
0
votes
0answers
27 views

Made a light controller for the holidays

I am a new the world of Arduino. I found on YouTube, how to build a light controller (https://www.youtube.com/watch?v=WvG9c84ApFA&t=39s). I follow every step but it doesn't work. Here are some ...
0
votes
3answers
86 views

pin going high not allowing analog read to change

I have the following problem: My arduino takes analogRead(A0) from a potentiometer whose position I can't adjust directly. When analogRead(AO) goes to a value X, I want pin 8 to go HIGH, this ...
-1
votes
1answer
45 views

Have I fried my arduino uno?

I made a smart dustbin using arduino, servo motor, & ultrasonic sensor. It worked pretty well for a few number of days. But once I don't know how but the Arduino 'ON' light started to become dim ...
0
votes
1answer
96 views

I don't know how to do the code for an rtc controlling a relay

I'm doing a project for my brother witch is an automatic watering thing, it's all working fine but I just don't know how to repeat the code to make the relay say come on for 5min at 0900 than 5min at ...
0
votes
1answer
51 views

'TCCR1B' was not declared in this scope

I'm trying to use a MS5540C (digital pressure sensor) and the sample code has this line: TCCR1B = (TCCR1B & 0xF8) | 1; //generates the MCLK signal I'm a bit of a noob to the IoT but its not ...
0
votes
0answers
35 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 ...
0
votes
0answers
33 views

HC-SRO4 always returns zero no matter what I do?

Wondering if it's the sensor or the code? can anyone help? I've used the code here /* HC-SR04 Ultrasonic Sensor with LCD dispaly HC-SR04 Ultrasonic Sensor VCC to Arduino 5V GND to Arduino GND ...
0
votes
2answers
41 views

Is digitalWrite(pinnumber,LOW) different from ground pin

I am using Tinkercad simulator, but an unusual thing happened. When I connect one wire of dc motor to pin 9 with digitalWrite(9,HIGH) and other wire to ground, the motor runs with rpm of 5555. void ...
0
votes
1answer
37 views

Where is tcp.h?

This is for an esp8266 project that uses EasyAsyncTCP. In EasyAsyncTCP.cpp they #include "lwip/tcp.h". But I can't figure out where that file is. I've found a tcp.h in the following directories on ...
0
votes
2answers
82 views

Dice is not showing the correct numbers

I've made a dice roller (to make it easier to roll the dice) using an Arduino UNO and an LCD keypad shield but I can't get the correct numbers (1, 6 (7)) to show up, I've tried using int, float and ...
0
votes
0answers
29 views

I cant seem to form a code to read both DHT11 and pulse sensor

I combined both the heart pulse sensor code and the DHT11 code. I can get a decent reading from the pulse sensor however an error is given from the DHT11 sensor. I am able to get them to function ...
0
votes
1answer
36 views

Expected unqualified-id before 'public'

I'm making an arduino program for a buzzer that you can record notes and song for and then play them back. I have 2 arrays that hold both pitch and if a note is being played. I continue to get errors ...
0
votes
2answers
44 views

Why can't I control speed of the motor? (M1 and E1)

When myservo_1,myservo_2,myservo_3,myservo_4 is commented, I can't control the speed of my M1 motor. But only when I uncomment myservo_1 and so on, I can control the motor speed again. Can someone ...
0
votes
2answers
54 views

Using an Arduino Nano to program (as ISP) a standalone 328p

I uploaded the ArduinoISP sketch to an Arduino Nano to use it as a programmer for other chips. It worked successfully to program an ATtiny45, I did the usual wiring between them, and added a 10uF ...
0
votes
0answers
69 views

pin change interrupt on arduino Due

Greeting! I am finding it difficult setting up a pin change interrupt on an arm board ( I am using Arduino due). I found a sample online which I have used but I discovered that when ever an interrupt ...
0
votes
1answer
23 views

Blink Adafruit_NeoPixel

I wish to blink all the strip. In the code below it just blink the first LED, how can I fix it? Code: #include <Adafruit_NeoPixel.h> #define PIN 6 #define NUM_LEDS 24 Adafruit_NeoPixel strip ...