Questions tagged [loop]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
119 views

Sending values with pyserial does not function if there is also sensing on Arduino Due

I'm using an Arduino Due to make a feedback loop using python, but this does not seem to function. The python code I'm using is the following: from serial import Serial board = Serial('COM11',9600) ...
celestin's user avatar
-1 votes
1 answer
26 views

manage some output based on some parameter and rtc

i'm trying to create a program that given a configuration (i've used multiple struct nested) i need in loop() to check for each output if they need to be on or off and set the output accordingly let ...
Darkmagister's user avatar
1 vote
2 answers
79 views

Program to Multiply Numbers Won't Actually Multiply Them

I am trying to write a program which takes in a number of pairs to be multiplied, then prints out the result of each multiplication. Instead of doing this, the program just prints out the number of ...
JG98's user avatar
  • 21
0 votes
1 answer
183 views

if statement does not work with fraction, but works with decimal equivalent

I'm trying to trouble shoot a problem with my code and narrowed it down to my if statement not working with a fraction. The below code does not work and returns 0 for(float i=0; i <= 1; i += .0001){...
LB Burkhardt's user avatar
1 vote
0 answers
56 views

How to change between loops? IR Remote + led strip

#include <IRremote.h> #include <Adafruit_NeoPixel.h> #define LED_PIN 7 // define the LED strip data pin #define LED_COUNT 150 // define the number of LEDs in the strip Adafruit_NeoPixel ...
Martin's user avatar
  • 11
0 votes
1 answer
124 views

Replace char based on user input

I am developing a hangman game on tinyduino(tinycircuits) and I am currently stuck on how to properly replace a char based on user input within a for loop. My current code does actually replace the ...
Isaac Agatep's user avatar
2 votes
1 answer
98 views

for loop crashes program

Just started out with tinyduino(tinycircuits) and I am trying to develop a hangman game. I have this chunk of code that randomly picks a word from my array. I've omitted some code for readability. ...
Isaac Agatep's user avatar
-1 votes
1 answer
110 views

How to write a program to do 2 different loop | Task?

I wanna write a program for rc-plane navigation The plane must navigate to 2 waypoints waypoint_1 & waypoint_2 When it reaches to waypoint_1 (with miss-distance =< 5) then navigate to ...
Curious guy's user avatar
-1 votes
2 answers
245 views

Char array filling with blanks

When I run this code, my pin and pinCheck arrays are not being filled with the results of keypad.getKey(). If I print the value at each index, the result is blank. As far as I can tell, I am either ...
Ryan's user avatar
  • 3
1 vote
2 answers
2k views

Circular buffer implementation and Serial.print()

I am trying to implement the simplest circular buffer in Arduino. I think I am able to implement it because my push and pop functions do not return any errors. However, when I want to print the data ...
TheClem's user avatar
  • 11
2 votes
2 answers
460 views

Arduino fade in/out 5 leds circuit acting wierd

I have a simple arduino project with 5 leds, the project should start with led 1 fade through 50 millisec to reach full brightness, then led 2 and so on until led 5 then turn them all off and loop. ...
AhmedH2O's user avatar
  • 123
-1 votes
1 answer
45 views

'for loop' seems to change the execution of pow()

The first time, pow() works. But inside of a 'for loop', or again afterwards, it doesn't behave !? (I'm using a Chinese Pro Mini with Arduino 1.8.16) EDIT To clarify what I am asking, my question is:...
TRS-80's user avatar
  • 21
1 vote
2 answers
540 views

Is there a need to put a delay in the main loop

Im a complete beginner. Generally speaking, is there any need at all to have a delay in the main loop()? Im not used to writing infinite loops 😀 Is it correct to say that the delay() command is ...
Megan Spencer's user avatar
5 votes
3 answers
2k views

How do I make another action repeat inside a loop?

So, I've just started programming Arduino (and also in general), so I'm doing basic things, like switching on and off LED's. I've made them light in a sequence and then turning them off (in the same ...
AndreFro's user avatar
2 votes
2 answers
152 views

Stuck In While Loop

So I'm a beginner at Arduino and I have to light up an LED grid to show digits from 0-9. I wrote a bit of code (with the help of some people) and it's like 90% done but there's this ONE problem. I ...
BertjeDP2000's user avatar
1 vote
1 answer
810 views

Detect button press in a loop

I am designing simple "Simon Says game" using Arduino. Simon says is a game in which a LED pattern is played and user has to mimic the pattern. There are 10 Rounds. First Round = 1 led, ...
Snoke's user avatar
  • 23
0 votes
1 answer
109 views

How fast does the Arduino execute code?

I am using the Arduino Nano every. Take this example where I am measuring two things A and B. Loop{// this loop runs once every second //Read A,B //Change something using analogueWrite which ...
fred's user avatar
  • 101
0 votes
1 answer
26 views

Run computation only on request over serial

An Arduino Nano is set up to perform A/D conversions and send results out over Serial. Currently the code structure is like loop() { delayUntilNextTargetTime(); measure(); ...
Harald's user avatar
  • 133
2 votes
1 answer
123 views

Error trying to simulate temperature dynamically

I'm trying to simulate dynamic temperature using a small set of data with ESP32. I've just realized that the relay doesn't change the status if there is some variation of the temperature upper or ...
s_tatus3's user avatar
1 vote
1 answer
562 views

Why is this extremely simple code not working?

I have a problem with a for loop, and Serial.print("Its Working") does not appear. Seems simple, I've done it before, now for whatever reason, its not working anymore void setup() { // put ...
Coder9390's user avatar
  • 472
2 votes
3 answers
652 views

How do I make my piezo buzzer only hum once without repetition?

I have a problem with getting my buzzer to only do the tones I programmed in once. I know I have to add some sort of code but I'm relatively new to this so I don't really know. I want it to start ...
Éemia's user avatar
  • 33
1 vote
2 answers
405 views

How do I pause a loop just once?

I´m trying to make a pause in a loop, but just for the first time it loops. The next loops i would like the program to NOT do the pause. Just once time, each time a button is pressed. Does anybody ...
Juan Antonio's user avatar
2 votes
1 answer
115 views

Any advice on how to repeat the song 6 times instead of infinitely?

//Here is my code so far int speakerPin = 9; int length = 28; char notes[] = "GGAGcB GGAGdc GGxecBA yyecdc"; int beats[] = { 2, 2, 8, 8, 8, 16, 1, 2, 2, 8, 8,8, 16, 1, 2,2,8,8,8,8,16, 1,...
William Woodard's user avatar
1 vote
1 answer
130 views

Rotating Servo Motor using Arduino

Using arduino, I'm trying to rotate a 360 servo that will move clockwise 5 seconds,pause and counterclockwise for 5 seconds and then completely stop. However, my servo just continuously keeps on ...
Asif's user avatar
  • 11
0 votes
1 answer
30 views

I have three pushbuttons where only one can be pushed at a time and want to set a variable for this. How?

Basically I have three push buttons that correspond to pins 1 to 3 and want to set an efficient code that sets a certain variable into the index whose digitalRead is equal to one. Let us assume that ...
AndroidV11's user avatar
0 votes
1 answer
72 views

How can I stop my servo looping when my sensor doesn't detect movement?

I have this project with my Arduino UNO where I want my servo motor SG90 to go full speed to 180 degrees when the PIR sensor sends HIGH value and go slowly back to zero when the value is LOW. I have ...
Nathan Ghali's user avatar
1 vote
0 answers
82 views

How to make my sensor reads when i pressed the button

Hi I'm making a digital fare meter, I have a problem in how my sensor reads when I'd pressed the button(single tap). I need the sensor to read once I pressed the button because when I press the button ...
SkilleX's user avatar
  • 11
1 vote
0 answers
285 views

Setting a fixed receiver frequency RDA5807m

I am using the receiver RDA5807m, but I do NOT need to switch the frequency and other parameters during operation. I noticed that the module continues to work when the programming pins are ...
Антон's user avatar
1 vote
0 answers
71 views

Infared: some controllers send code into infinite loop

I have a piece of code that captures input from infrared and spits it out to the serial port. When I use it with a simple controller that comes with a typical kit, it receives the infrared code just ...
brad's user avatar
  • 201
0 votes
1 answer
98 views

How to stop the relay after it is getting on and let the sensor get the result

I want to provide a delay in the following iteration reading so that the sensor can read the condition after the pump starts. void loop() { //-------------Fungsi Read sensor----------- // ...
daffa faiz's user avatar
1 vote
2 answers
132 views

How can I have different routines fire off at different intervals

I'm making an interface that will have a digital clock....once a second.. I'd like to do other things at different intervals but if I delay(1000) then I have to wait that second which is now the ...
BostonMacOSX's user avatar
1 vote
0 answers
167 views

how to control 2 sensor and 3 relay with fuzzy

i'm using fuzzy to decide how long the relay on pump on and i got some trouble for it he just looping on relay how should i do thats my code //---------Fuzzy 2.1 prelauch---------- //-----iNPUT ...
daffa faiz's user avatar
1 vote
1 answer
163 views

Storing and sequencing output value (Arduino)

I am new to Arduino programming, after days and nights trying to use array and for loop, and googling a lot of articles, I am still unable to find how to store each weighing output value from int ...
FlipFlop's user avatar
1 vote
0 answers
49 views

My circuit is being goofy with regards to my PIR sensor

Here is the code I've written so far. I am making a circuit with a couple of motors and 3 sensors. My plan is for the PIR Motion sensor, distance sensor, and photoresistor to tell the motors to stop ...
Guest's user avatar
  • 11
2 votes
0 answers
54 views

Two LED Patterns Task Controlled by GUI

I am very new to Arduino and coding/programing. I set a task for myself to make a simple circuit of 5 LEDs controlled by pins 2, 4, 8, 11, 12. I want to be able to make two different pattern for the ...
Tayler Hasson's user avatar
2 votes
1 answer
57 views

Input state is stuck HIGH when function called using input also uses same input to call another function

I'm writing a choose-your-own-adventure style project for a class project. My Arduino Uno is set up with a 16-digit LCD display and two pushbuttons with pulldown resistors. I'm wanting each function ...
Snyper's user avatar
  • 41
0 votes
1 answer
9k views

Blink LED 5 times with for loop

Is it possible to let a LED blink, for example 5 times, with an Arduino? Should I use a for loop? Something like this works in setup, but it will run continuously in the void loop, so my LED keeps ...
Niles's user avatar
  • 123
1 vote
1 answer
56 views

Cutting neopixel routine code short

I've been working on a level meter with a neopixel strip (WS2812). The code is very simple: reading a potentiometer, mapping the input and showing the output in the led strip. So far, so good. The ...
Vidal's user avatar
  • 13
1 vote
1 answer
261 views

For Loop function to iterate through outputs after interrupt

I would like help to continuously loop over my output pins after each sleep cycle. I am trying to increment through each output pin during each successive interrupt. Introducing this myIteration ...
chirp84's user avatar
  • 21
1 vote
4 answers
3k 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.
Time Gold's user avatar
  • 103
2 votes
1 answer
126 views

Wifi strength Automation . Help. Noobie here

#include <ESP8266WiFi.h> const char *SSID = "mr_lazy_boei"; const char *pass = "usalusal"; WiFiClient client; // Relay pin number int ignition=2; int self=0; // Return ...
Mohd Usal's user avatar
1 vote
1 answer
449 views

Mega 2560 does not play audio file when I want. It plays when the first condition is met, but not the other

Okay, so I am making a jewelry box for my niece that will spin a necklace holder with a stepper motor, play an audio file and turn on LED lights. I am using an Arduino MEGA 2560. The flow is this: ...
Vincent Ledbetter's user avatar
1 vote
3 answers
2k views

Why are the Do While loops not stopping?

Ive been staring at this for a while now and I am going cross-eyed. I am writing a simply program to change colors of a 3 color LED. It is working, but then I noticed the LED would sometimes flash. ...
Keltari's user avatar
  • 163
1 vote
0 answers
54 views

Code is not looping correctly when running on battery

static const int dry = 570; static const int wet = 225; static const int RELAY = 2; static const unsigned long DELAY_1_S = 1000; static const unsigned long DELAY_1_MINUTE = DELAY_1_S * 60; static ...
Patrick Vibild's user avatar
1 vote
1 answer
193 views

Breaking out of the arduino fingerprint enroll loop

I am using the Arduino's Adafruit Finger Sensor library, and it has an example to enroll a fingerprint. I want it to enroll one print and exit/break out of the loop because it currently enrolls a user,...
Ngugi Kariuki's user avatar
1 vote
1 answer
32 views

Check if any of loop's insides returns 1 and hold it until the whole loop is 0 again

I'm new to this, so, please, don't crucify me. I have a function that checks if an entry in multilevel array is in a certain range. Using FOR loop I check the whole array with this function, which ...
Martin Keller II.'s user avatar
1 vote
0 answers
599 views

Looping a defined function to show live variables printed on OLED screen

I have started a thread on the Arduino forum. If someone could have a look at the thread and give me some help either here or there that would be great. (I don't want to have to add all the ...
jburke424's user avatar
1 vote
1 answer
59 views

Is it possible to exit a loop on the change of an input state?

I would like to exit a particular loop if the state of an input changes from LOW to HIGH. This is the current loop: void brakeFade() { pixels.clear(); pixels.setBrightness(255); pixels.fill(16711680, ...
JabawokJayUK's user avatar
-1 votes
1 answer
113 views

Exit from for function after detecting obstacles

#include <HCSR04.h> int red = 13; int green = 12; int blue = 11; int trigger = 9; int echo = 8; int halt; void setup(){ pinMode(red, OUTPUT); pinMode(green, OUTPUT); pinMode(blue, OUTPUT)...
tommy's user avatar
  • 29
-1 votes
2 answers
256 views

Make a code loop 100 times with a text on Serial Monitor

Ok, this is my code: int rosso = 13; int verde = 12; int blu = 11; int count = 0; String command_on, command_off; String s; String enough = "stop"; void setup(){ pinMode(rosso, OUTPUT); ...
tommy's user avatar
  • 29