SlideShare una empresa de Scribd logo
1 de 26
Descargar para leer sin conexión
Variables
Variables
Variables
Variable data types
int value = 150 ;
char chr_a = ‘a’ ;
Variable scope
Int X = 0 ; Global variable declaration
Void setup () {
}
Void loop () {
int z = 0 ; Local variable declaration
}
Strings
void loop() {
char my_str[6];
my_str[0] = 'H';
my_str[1] = 'e';
my_str[2] = 'l';
my_str[3] = 'l';
my_str[4] = 'o';
char like[] = "I like coffee and cake";
}
Arrays
type arrayName [ arraySize ] ;
int C[ 12 ]; // C is an array of 12 integers
Control structures
if
if...else
switch...case
do
do...while
for
*jump statements:
continue, goto,
break
Functions
Functions
int pin = 13;
void setup()
{
pinMode(pin, OUTPUT);
}
void loop()
{
dot(); dot(); dot();
dash(); dash(); dash();
dot(); dot(); dot();
delay(3000);
}
void dot()
{
digitalWrite(pin, HIGH);
delay(250);
digitalWrite(pin, LOW);
delay(250);
}
void dash()
{
digitalWrite(pin, HIGH);
delay(1000);
digitalWrite(pin, LOW);
delay(250);
}
Operators
Arithmetic Operators
Comparison Operators
Boolean Operators
Bitwise Operators
Compound Operators
Arithmetic Operators
+ - * / % =
void loop () {
int a = 9, b = 4, c;
c = a + b;
c = a – b;
c = a * b;
c = a / b;
c = a % b;
}
Arithmetic Operators
+ - * / % =
void loop () {
int a = 9, b = 4, c;
c = a + b; //13
c = a – b; //5
c = a * b; //36
c = a / b; //2
c = a % b; //1
}
Comparison Operators
== != < > <= >=
void loop () {
int a = 9, b = 4
if(a == b){}
if(a != b){}
if(a < b){}
if(a > b){}
if(a <= b){}
if(a >= b){}
}
Comparison Operators
== != < > <= >=
void loop () {
int a = 9, b = 4
if(a == b){} // false
if(a != b){} // true
if(a < b){} // false
if(a > b){} // true
if(a <= b){} // false
if(a >= b){} // true
}
Boolean Operators
&& || !
void loop () {
int a = 9, b = 4
if((a > b) && (b < a)){}
if((a == b) || (b < a)){}
if( !(a == b) && (b < a)){}
}
Boolean Operators
&& || !
void loop () {
int a = 9, b = 4
if((a > b) && (b < a)){} // true
if((a == b) || (b < a)){} // true
if( !(a == b) && (b < a)){} // true
}
Bitwise Operators
& | ^ ~ << >>
void loop () {
int a = 10; // 0b00001010
int b = 20; // 0b00010100
int c;
c = a & b ;
c = a | b ;
c = a ^ b ;
c = ~a ;
c = a << 2 ;
c = b >> 2 ;
}
Bitwise Operators
& | ^ ~ << >>
void loop () {
int a = 10; // 0b00001010
int b = 20; // 0b00010100
int c;
c = a & b ; // 0b00000000
c = a | b ; // 0b00011110
c = a ^ b ; // 0b00011110
c = ~a ; // 0b11110101
c = a << 2 ; // 0b00101000
c = b >> 2 ; // 0b00000101
}
Bitwise Operators
++ – += -= *= /= %= |= &=
void loop () {
int a = 10, b = 20
int c = 0;
a++;
a--;
b += a; // b=b+a
b -= a; // b=b-a
}
Bitwise Operators
++ – += -= *= /= %= |= &=
void loop () {
int a = 10, b = 20
int c = 0;
a++; // 11
a--; // 9
b += a; // 30
b -= a; // 10
}
Challenges:
1. Take user input from the keyboard to change the color of an RGB LED.
https://www.arduino.cc/en/Tutorial/BuiltInExamples/SwitchCase2
2. Create an array of 255 distinct values (bonus if the numbers are meaningful in some way).
https://www.arduino.cc/reference/en/language/variables/data-types/array/
3. Tell if a user's input was even or odd.
https://www.tutorialspoint.com/arduino/arduino_arithmetic_operators.htm
4. Take a diameter of a circle from the user and return the circumference as a decimal (e.g. 8.56930).
https://www.arduino.cc/reference/en/language/variables/data-types/float/
5. BONUS: Make code that generates abstract ASCII art/drawings in the serial monitor!!
https://en.wikipedia.org/wiki/ASCII_art
https://manytools.org/hacker-tools/convert-images-to-ascii-art/
6. *BONUS BONUS*: Make a text-based "Choose your own adventure" video game!!
https://en.wikipedia.org/wiki/Colossal_Cave_Adventure
https://en.wikipedia.org/wiki/Choose_Your_Own_Adventure
Challenges:
1. Take user input from the keyboard to change the color of an RGB LED.
https://www.arduino.cc/en/Tutorial/BuiltInExamples/SwitchCase2
void setup() {
Serial.begin(9600);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() {
if(Serial.available() > 0) {
int inByte = Serial.read();
switch (inByte) {
case 'a':
digitalWrite(3, HIGH);
break;
case 'b':
digitalWrite(4, HIGH);
break;
case 'c':
digitalWrite(5, HIGH);
break;
}
}
}
Challenges:
2. Create an array of 255 distinct values (bonus if the numbers are meaningful in some way).
https://www.arduino.cc/reference/en/language/variables/data-types/array/
void setup(){
Serial.begin(9600);
}
void loop(){
delay(100);
int my_array[252];
for (int i = 0; i < 252; i++) {
my_array[i]=i;
delay(100);
Serial.println(my_array[i]);
}
}
OR:
int A[255]; //create an array composed of 255 elements
void setup() {
Serial.begin(9600); //initialize the serial monitor
for( int i = 254; i >= 0; i--){ //initialize a variable "i" which the value decrements until it reaches 0.
A[i] = i; //define an element of the array as "i"
Serial.println(A[i]); //display the array in the serial monitor
}
}
void loop() {
}
Challenges:
3. Tell if a user's input was even or odd.
https://www.tutorialspoint.com/arduino/arduino_arithmetic_operators.htm
int incomingByte = 0; //Create a variable for the data input
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) { //read the sensor
incomingByte = Serial.read();
}
if (incomingByte%2 == 0){ //if the number read is divisible by two
Serial.println ("even"); //it is an even number
}
else { //otherwise
Serial.println ("odd"); //the value remaining means it is an odd number
}
}
Challenges:
4. Take a diameter of a circle from the user and return the circumference as a decimal (e.g. 8.56930).
https://www.arduino.cc/reference/en/language/variables/data-types/float/
float Pi = 3.14; //Create a variable Pi
int d = 0; //Creat a variable "d" as diameter
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0.0) {
d = Serial.read()-48; //convert from ASCII to integer
float c = Pi * (float(d)); //Create "c", Circonference is equal to Pi x diameter
Serial.println(c);
}
}

Más contenido relacionado

La actualidad más candente

C Code and the Art of Obfuscation
C Code and the Art of ObfuscationC Code and the Art of Obfuscation
C Code and the Art of Obfuscationguest9006ab
 
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -Wataru Kani
 
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...DevGAMM Conference
 
Documento de acrobat2
Documento de acrobat2Documento de acrobat2
Documento de acrobat2fraytuck
 
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
Writing SOLID C++ [gbgcpp meetup @ Zenseact]Writing SOLID C++ [gbgcpp meetup @ Zenseact]
Writing SOLID C++ [gbgcpp meetup @ Zenseact]Dimitrios Platis
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxyginecorehard_by
 
How to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftHow to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftGiordano Scalzo
 
Oxygine 2 d objects,events,debug and resources
Oxygine 2 d objects,events,debug and resourcesOxygine 2 d objects,events,debug and resources
Oxygine 2 d objects,events,debug and resourcescorehard_by
 
Cocos2d Performance Tips
Cocos2d Performance TipsCocos2d Performance Tips
Cocos2d Performance TipsKeisuke Hata
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good codeGiordano Scalzo
 
Php radomize
Php radomizePhp radomize
Php radomizedo_aki
 
Minerva_lib - fuzzing tool
Minerva_lib - fuzzing toolMinerva_lib - fuzzing tool
Minerva_lib - fuzzing toolLogicaltrust pl
 
HailDB: A NoSQL API Direct to InnoDB
HailDB: A NoSQL API Direct to InnoDBHailDB: A NoSQL API Direct to InnoDB
HailDB: A NoSQL API Direct to InnoDBstewartsmith
 
Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6fisher.w.y
 
A simple snake game project
A simple snake game projectA simple snake game project
A simple snake game projectAmit Kumar
 
ECMAScript2015
ECMAScript2015ECMAScript2015
ECMAScript2015qmmr
 
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)hasan0812
 

La actualidad más candente (20)

C Code and the Art of Obfuscation
C Code and the Art of ObfuscationC Code and the Art of Obfuscation
C Code and the Art of Obfuscation
 
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
第二回 冬のスイッチ大勉強会 - FullColorLED & MPU-6050編 -
 
C++ L10-Inheritance
C++ L10-InheritanceC++ L10-Inheritance
C++ L10-Inheritance
 
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
 
Documento de acrobat2
Documento de acrobat2Documento de acrobat2
Documento de acrobat2
 
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
Writing SOLID C++ [gbgcpp meetup @ Zenseact]Writing SOLID C++ [gbgcpp meetup @ Zenseact]
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxygine
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
How to Clone Flappy Bird in Swift
How to Clone Flappy Bird in SwiftHow to Clone Flappy Bird in Swift
How to Clone Flappy Bird in Swift
 
Oxygine 2 d objects,events,debug and resources
Oxygine 2 d objects,events,debug and resourcesOxygine 2 d objects,events,debug and resources
Oxygine 2 d objects,events,debug and resources
 
Cocos2d Performance Tips
Cocos2d Performance TipsCocos2d Performance Tips
Cocos2d Performance Tips
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good code
 
Php radomize
Php radomizePhp radomize
Php radomize
 
Minerva_lib - fuzzing tool
Minerva_lib - fuzzing toolMinerva_lib - fuzzing tool
Minerva_lib - fuzzing tool
 
HailDB: A NoSQL API Direct to InnoDB
HailDB: A NoSQL API Direct to InnoDBHailDB: A NoSQL API Direct to InnoDB
HailDB: A NoSQL API Direct to InnoDB
 
Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6
 
A simple snake game project
A simple snake game projectA simple snake game project
A simple snake game project
 
ECMAScript2015
ECMAScript2015ECMAScript2015
ECMAScript2015
 
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)
 
Myraytracer
MyraytracerMyraytracer
Myraytracer
 

Similar a Arduino coding class

include ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfinclude ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfcontact32
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th StudyChris Ohk
 
The following is my code for a connectn program. When I run my code .pdf
The following is my code for a connectn program. When I run my code .pdfThe following is my code for a connectn program. When I run my code .pdf
The following is my code for a connectn program. When I run my code .pdfeyelineoptics
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_papervandna123
 
Effective C#
Effective C#Effective C#
Effective C#lantoli
 
Arduino sectionprogramming slides
Arduino sectionprogramming slidesArduino sectionprogramming slides
Arduino sectionprogramming slidesJorge Joens
 
Arduino section programming slides
Arduino section programming slidesArduino section programming slides
Arduino section programming slidesvivek k
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IOT Academy
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programmingPrabhu Govind
 
NetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf EditionNetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf EditionPaulo Morgado
 
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...GkhanGirgin3
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...ssuserd6b1fd
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statementsMomenMostafa
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Ismar Silveira
 
Arduino Section Programming - from Sparkfun
Arduino Section Programming - from SparkfunArduino Section Programming - from Sparkfun
Arduino Section Programming - from SparkfunJhaeZaSangcapGarrido
 

Similar a Arduino coding class (20)

include ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfinclude ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdf
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th Study
 
The following is my code for a connectn program. When I run my code .pdf
The following is my code for a connectn program. When I run my code .pdfThe following is my code for a connectn program. When I run my code .pdf
The following is my code for a connectn program. When I run my code .pdf
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
Effective C#
Effective C#Effective C#
Effective C#
 
Quiz 9
Quiz 9Quiz 9
Quiz 9
 
Arduino sectionprogramming slides
Arduino sectionprogramming slidesArduino sectionprogramming slides
Arduino sectionprogramming slides
 
Arduino section programming slides
Arduino section programming slidesArduino section programming slides
Arduino section programming slides
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programming
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programming
 
NetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf EditionNetPonto - The Future Of C# - NetConf Edition
NetPonto - The Future Of C# - NetConf Edition
 
C programming
C programmingC programming
C programming
 
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
 
Arduino Section Programming - from Sparkfun
Arduino Section Programming - from SparkfunArduino Section Programming - from Sparkfun
Arduino Section Programming - from Sparkfun
 
Tu1
Tu1Tu1
Tu1
 
DataTypes.ppt
DataTypes.pptDataTypes.ppt
DataTypes.ppt
 
pointers 1
pointers 1pointers 1
pointers 1
 

Más de Jonah Marrs

Etapes fab-venti-v2
Etapes fab-venti-v2Etapes fab-venti-v2
Etapes fab-venti-v2Jonah Marrs
 
Arduino creative coding class part iii
Arduino creative coding class part iiiArduino creative coding class part iii
Arduino creative coding class part iiiJonah Marrs
 
Arduino workshop
Arduino workshopArduino workshop
Arduino workshopJonah Marrs
 
Shop bot training
Shop bot trainingShop bot training
Shop bot trainingJonah Marrs
 
Microcontroller primer
Microcontroller primerMicrocontroller primer
Microcontroller primerJonah Marrs
 
Eagle pcb tutorial
Eagle pcb tutorialEagle pcb tutorial
Eagle pcb tutorialJonah Marrs
 

Más de Jonah Marrs (8)

Sensors class
Sensors classSensors class
Sensors class
 
Etapes fab-venti-v2
Etapes fab-venti-v2Etapes fab-venti-v2
Etapes fab-venti-v2
 
Arduino creative coding class part iii
Arduino creative coding class part iiiArduino creative coding class part iii
Arduino creative coding class part iii
 
Assembly class
Assembly classAssembly class
Assembly class
 
Arduino workshop
Arduino workshopArduino workshop
Arduino workshop
 
Shop bot training
Shop bot trainingShop bot training
Shop bot training
 
Microcontroller primer
Microcontroller primerMicrocontroller primer
Microcontroller primer
 
Eagle pcb tutorial
Eagle pcb tutorialEagle pcb tutorial
Eagle pcb tutorial
 

Último

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 

Último (20)

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 

Arduino coding class

  • 4. Variable data types int value = 150 ; char chr_a = ‘a’ ;
  • 5. Variable scope Int X = 0 ; Global variable declaration Void setup () { } Void loop () { int z = 0 ; Local variable declaration }
  • 6. Strings void loop() { char my_str[6]; my_str[0] = 'H'; my_str[1] = 'e'; my_str[2] = 'l'; my_str[3] = 'l'; my_str[4] = 'o'; char like[] = "I like coffee and cake"; }
  • 7. Arrays type arrayName [ arraySize ] ; int C[ 12 ]; // C is an array of 12 integers
  • 10. Functions int pin = 13; void setup() { pinMode(pin, OUTPUT); } void loop() { dot(); dot(); dot(); dash(); dash(); dash(); dot(); dot(); dot(); delay(3000); } void dot() { digitalWrite(pin, HIGH); delay(250); digitalWrite(pin, LOW); delay(250); } void dash() { digitalWrite(pin, HIGH); delay(1000); digitalWrite(pin, LOW); delay(250); }
  • 11. Operators Arithmetic Operators Comparison Operators Boolean Operators Bitwise Operators Compound Operators
  • 12. Arithmetic Operators + - * / % = void loop () { int a = 9, b = 4, c; c = a + b; c = a – b; c = a * b; c = a / b; c = a % b; }
  • 13. Arithmetic Operators + - * / % = void loop () { int a = 9, b = 4, c; c = a + b; //13 c = a – b; //5 c = a * b; //36 c = a / b; //2 c = a % b; //1 }
  • 14. Comparison Operators == != < > <= >= void loop () { int a = 9, b = 4 if(a == b){} if(a != b){} if(a < b){} if(a > b){} if(a <= b){} if(a >= b){} }
  • 15. Comparison Operators == != < > <= >= void loop () { int a = 9, b = 4 if(a == b){} // false if(a != b){} // true if(a < b){} // false if(a > b){} // true if(a <= b){} // false if(a >= b){} // true }
  • 16. Boolean Operators && || ! void loop () { int a = 9, b = 4 if((a > b) && (b < a)){} if((a == b) || (b < a)){} if( !(a == b) && (b < a)){} }
  • 17. Boolean Operators && || ! void loop () { int a = 9, b = 4 if((a > b) && (b < a)){} // true if((a == b) || (b < a)){} // true if( !(a == b) && (b < a)){} // true }
  • 18. Bitwise Operators & | ^ ~ << >> void loop () { int a = 10; // 0b00001010 int b = 20; // 0b00010100 int c; c = a & b ; c = a | b ; c = a ^ b ; c = ~a ; c = a << 2 ; c = b >> 2 ; }
  • 19. Bitwise Operators & | ^ ~ << >> void loop () { int a = 10; // 0b00001010 int b = 20; // 0b00010100 int c; c = a & b ; // 0b00000000 c = a | b ; // 0b00011110 c = a ^ b ; // 0b00011110 c = ~a ; // 0b11110101 c = a << 2 ; // 0b00101000 c = b >> 2 ; // 0b00000101 }
  • 20. Bitwise Operators ++ – += -= *= /= %= |= &= void loop () { int a = 10, b = 20 int c = 0; a++; a--; b += a; // b=b+a b -= a; // b=b-a }
  • 21. Bitwise Operators ++ – += -= *= /= %= |= &= void loop () { int a = 10, b = 20 int c = 0; a++; // 11 a--; // 9 b += a; // 30 b -= a; // 10 }
  • 22. Challenges: 1. Take user input from the keyboard to change the color of an RGB LED. https://www.arduino.cc/en/Tutorial/BuiltInExamples/SwitchCase2 2. Create an array of 255 distinct values (bonus if the numbers are meaningful in some way). https://www.arduino.cc/reference/en/language/variables/data-types/array/ 3. Tell if a user's input was even or odd. https://www.tutorialspoint.com/arduino/arduino_arithmetic_operators.htm 4. Take a diameter of a circle from the user and return the circumference as a decimal (e.g. 8.56930). https://www.arduino.cc/reference/en/language/variables/data-types/float/ 5. BONUS: Make code that generates abstract ASCII art/drawings in the serial monitor!! https://en.wikipedia.org/wiki/ASCII_art https://manytools.org/hacker-tools/convert-images-to-ascii-art/ 6. *BONUS BONUS*: Make a text-based "Choose your own adventure" video game!! https://en.wikipedia.org/wiki/Colossal_Cave_Adventure https://en.wikipedia.org/wiki/Choose_Your_Own_Adventure
  • 23. Challenges: 1. Take user input from the keyboard to change the color of an RGB LED. https://www.arduino.cc/en/Tutorial/BuiltInExamples/SwitchCase2 void setup() { Serial.begin(9600); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); } void loop() { if(Serial.available() > 0) { int inByte = Serial.read(); switch (inByte) { case 'a': digitalWrite(3, HIGH); break; case 'b': digitalWrite(4, HIGH); break; case 'c': digitalWrite(5, HIGH); break; } } }
  • 24. Challenges: 2. Create an array of 255 distinct values (bonus if the numbers are meaningful in some way). https://www.arduino.cc/reference/en/language/variables/data-types/array/ void setup(){ Serial.begin(9600); } void loop(){ delay(100); int my_array[252]; for (int i = 0; i < 252; i++) { my_array[i]=i; delay(100); Serial.println(my_array[i]); } } OR: int A[255]; //create an array composed of 255 elements void setup() { Serial.begin(9600); //initialize the serial monitor for( int i = 254; i >= 0; i--){ //initialize a variable "i" which the value decrements until it reaches 0. A[i] = i; //define an element of the array as "i" Serial.println(A[i]); //display the array in the serial monitor } } void loop() { }
  • 25. Challenges: 3. Tell if a user's input was even or odd. https://www.tutorialspoint.com/arduino/arduino_arithmetic_operators.htm int incomingByte = 0; //Create a variable for the data input void setup() { Serial.begin(9600); } void loop() { if (Serial.available() > 0) { //read the sensor incomingByte = Serial.read(); } if (incomingByte%2 == 0){ //if the number read is divisible by two Serial.println ("even"); //it is an even number } else { //otherwise Serial.println ("odd"); //the value remaining means it is an odd number } }
  • 26. Challenges: 4. Take a diameter of a circle from the user and return the circumference as a decimal (e.g. 8.56930). https://www.arduino.cc/reference/en/language/variables/data-types/float/ float Pi = 3.14; //Create a variable Pi int d = 0; //Creat a variable "d" as diameter void setup() { Serial.begin(9600); } void loop() { if (Serial.available() > 0.0) { d = Serial.read()-48; //convert from ASCII to integer float c = Pi * (float(d)); //Create "c", Circonference is equal to Pi x diameter Serial.println(c); } }