Lesson 56: What is a function? | Arduino Step-by-Step Course
484-Lesson 56: What is a function? | Arduino Step-by-Step Course
Язык: C++
/*
* S06-01
Lesson 56: What is a function? | Arduino Step By Step Course
* This is an Arduino sketch to demonstrate "functions" in Arduino.
Please watch the video for full details: https://youtu.be/KRTnaSYOEmQ
* Written by Ahmad Shamshiri for Robojax.com and the Robojax YouTube channel
* on January 3, 2019 at 3:25 PM 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 downloaded 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 the Serial monitor
@param t is a String text
@ returns nothing
*/
void printText(String t)
{
Serial.println(t);
}
/*
* getDays calculates the number of days in a year
* @param a is an integer
* @param returns an integer value representing the number of days
*/
int getDays(int a)
{
return (a * 365);// multiply a by 365 to get the 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 the value of pi
}
float getPower(float i)
{
return i*voltage;//
}
Ресурсы и ссылки
Ресурсов пока нет.
Файлы📁
Нет доступных файлов.