Back to Arduino Step By Step Course
If you don't like to see ads while video is being played you can purchase this course for $200 from Udemy or purchase YouTube premium Here
In this lesson we learn how what a function is and how to define it. We learn about return type, about arguments and parameters.
/*
* S06-01
Lesson 56 : What is a function? | Arduino Step By Step Course
* This is Arduino sketch to demonstrate "functions" in Arduino
Please watch video for full details: https://youtu.be/KRTnaSYOEmQ
* Written by Ahmad Shamshiri for Robojax.com and Robojax YouTube channel
* on Jan 03, 2019 at 15:25 in Ajax, Ontario, Canada
* This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.*
* This code has been download from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const float voltage = 3.3;
void setup() {
// Robojax Arduino floating points
Serial.begin(9600);// initialize the Serial Monitor
}
void loop() {
//3.141592
Serial.println( pi(), 10 );
//delay(1000);
}
/*
printText: prints the text on Serial monitor
@param t is String text
@ returns nothing
*/
void printText(String t)
{
Serial.println(t);
}
/*
* getDays is calculation the number of days in a year
* @param a is integer
* @param returns integer value of number of days
*/
int getDays(int a)
{
return (a * 365);// multiply a by 365 to get number of days and return it
}
float getArea(float l, float w)
{
float area = l * w;
return area;
}
String makeText(double temperature)
{
String newText;
if (temperature > 60.5)
{
newText = "Very hot";
}else{
newText = "Not hot";
}
return newText;
}
double pi()
{
double p = 3.141592;// 6 decimal points
return p;// returns value of pi
}
float getPower(float i)
{
return i*voltage;//
}
The least I expect from you is to thumb up the video and subscribe to my channel. I appriciate that. .I have spent months making these lectures and writing code. You don't lose anything by subscribging to my channel. Your subscription is stamp of approval to my videos and more people can find them and in it turn it helps me. Thank you
If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal
**** AFFILIATE PROGRAM **** We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.