Skip to main content

Questions tagged [functions]

Segmenting code into functions allows a programmer to create modular pieces of code that perform a defined task and then return to the area of code from which the function was "called". The typical case for creating a function is when one needs to perform the same action multiple times in a program.

4 votes
2 answers
5k views

I've got a problem using a default value for a function parameter. This code gives "'blink' was not declared in this scope": void loop(void) { blink(12, 2, 1000); } void blink(const ...
MichelBen's user avatar
4 votes
1 answer
171 views

Hey there Stack community. I'm working with the Particle Boron v4.1.0. I'm connecting a Garmin Lidar Lite V4 on I2C. I'm using the LIDARLite_v4LED.h header file found in the library given for this ...
Katie Neeley's user avatar
4 votes
1 answer
3k views

There is a library davetcc / IoAbstraction. The only library working as expected with my rotary encoder. The problem that on rotation I can only see serial output with position data, but I cannot get ...
max5555 max5555's user avatar
3 votes
1 answer
118 views

I'm just curious as to why there are no brackets at the end of the ISR when attaching and assigning the interrupt command? attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE); ... ...
Diesel's user avatar
  • 144
3 votes
1 answer
1k views

I am working in ESP8266 AsyncWebserver library and have been using this [](parameter) as an argument to some functions as shown below but does not really know what it means. Being a neophyte I am ...
Mr.B's user avatar
  • 57
3 votes
2 answers
307 views

Im currently moving a servo from one side to another by using the typical for loop like this: int lightON = 180; int lightOFF = 90; if (buttonState == HIGH) { digitalWrite(LED, HIGH); for (pos1 =...
Marcelo_M's user avatar
  • 121
3 votes
0 answers
23 views

This is my first question! i'm sorry if i'm doing something wrong. I'm trying to write a code that blinks some leds, but i cant quite work out how to use structs as arguments. This is the code: void ...
Dariem Fabián Hidalgo Arias's user avatar
2 votes
1 answer
383 views

What I want to do: I have 7 touch buttons on my board (ESP32 TTGO T-Display) and I want to attach interrupts to everyone, calling the same function. In this function I would like to use ...
Ruvian de Césaro's user avatar
2 votes
4 answers
938 views

Many arduino functions return -1 if something 'fails'. Serial.read for example returns -1 or the infamous ÿ when this function is called while the serial buffer is empty. As embedded C progammer, I ...
bas knippels's user avatar
2 votes
2 answers
7k views

Using the FastLED library, I want to light up multiple lights at once. Currently I am passing in just one light to the function. spell( int LEDNumber ) { FastLED.clear(); leds[LEDNumber] = ...
Joshua Dance's user avatar
2 votes
1 answer
84 views

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
2 votes
1 answer
8k views

Analyzing this and this answers under Arduino, which should be the proper way to pass a 2D array into a function? The function should be applicable to different sizes of 2D arrays. // NOT COMPILING ...
Brethlosze's user avatar
2 votes
1 answer
258 views

I have a single function for debugging messages, used through all the project. When KEYDEBUG is defined as 1 or 0, the function is enabled or disabled as required. #define KEYDEBUG 0 void debugging(...
Brethlosze's user avatar
2 votes
1 answer
49 views

You can try the code on your arduino UNO to better understand what is hapening in serial monitor! I want to calculate jacobian matrix from rotation matrix! float jakMATB[3][3] = { {0, 0, 0}, {0, 0, 0},...
boki's user avatar
  • 31
2 votes
1 answer
414 views

I would like to change the delay() into a nonblocking function in the code below. I've implemented it (a part of a tutorial from arduino.cc) in my code, but the delay() is blocking the rest of my code....
Joost's user avatar
  • 75

15 30 50 per page
1
2 3 4 5