Questions tagged [loop]
126 questions
5
votes
3 answers
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 sequence), and now I wanted to use 2 buttons, one…
AndreFro
- 53
- 6
4
votes
5 answers
Simultaneous button reading?
I'm currently working on a project that requires that I simultanously check the state of two buttons. Each button HIGH state is assigned to one if loop. Here's the basic concept:
void loop() {
S1_State = digitalRead(S1_Pin);
S2_State =…
oh double-you oh
- 43
- 1
- 4
3
votes
2 answers
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 simply helpful for tutorials (i.e turn light on, wait,…
user81200
3
votes
1 answer
Wire SlaveReceiver : will the registered function in onRecieve interrupt/conflict with loop block?
I am currently researching on I2C, and I made a configuration that has MasterWriter that transmits data to a SlaveReceiver that will store the data received from Master, into an SD card, and then transmit the same line of data by GPRS onto my back…
aharahap3112
- 31
- 1
3
votes
1 answer
Correct way of having loop end when required?
I'm brand new to Arduinos. I'm currently trying to modify a script from here which at the moment, simply turns an LED on or off depending on which HTTP GET request it receives. However, I want to modify this to have the LED modulate on/off when…
Tom
- 339
- 2
- 4
- 10
2
votes
1 answer
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.
char* words[] = {"Fortran", "Cobol", "Python",…
Isaac Agatep
- 23
- 5
2
votes
2 answers
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.
here is an image for the circuit (pardon the messy…
AhmedH2O
- 123
- 4
2
votes
2 answers
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 used a switch case to light up the LEDs (so if the…
BertjeDP2000
- 23
- 3
2
votes
1 answer
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 lower the threshold.
If the temperature starts below…
s_tatus3
- 83
- 6
2
votes
3 answers
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 playing the tones I have in the code once I press the…
Éemia
- 33
- 4
2
votes
1 answer
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,2,2,8,8,8,16 };
int tempo = 150;
void playTone(int tone,…
William Woodard
- 21
- 1
2
votes
0 answers
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 LEDs and be able to turn each pattern on or off…
Tayler Hasson
- 21
- 2
2
votes
1 answer
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 to display text on the LCD and then take two user…
Snyper
- 41
- 4
2
votes
1 answer
Wifi strength Automation . Help. Noobie here
#include
const char *SSID = "mr_lazy_boei";
const char *pass = "usalusal";
WiFiClient client;
// Relay pin number
int ignition=2;
int self=0;
// Return RSSI(Received Signal Strength Indicator) or 0 if target SSID not…
Mohd Usal
- 21
- 3
2
votes
2 answers
Arduino uno wifi rev2 stuck inside loop
It might be a stupid question but I can't figure it out. While running the code below. I want to open the box when the code matches the code in API. This all works. I can even close the box afterwords. But then I am stuck inside my loop. after the…
imkeVr
- 161
- 4