Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 2-2: Arduino Programming

Similar presentations


Presentation on theme: "Lecture 2-2: Arduino Programming"— Presentation transcript:

1 Lecture 2-2: Arduino Programming
Dr. Kyung Eun Park Summer 2017 Arduino Language Reference:

2 Arduino Programming Environment

3 Board Type Setting

4 Serial Port / COM Port

5 Arduino IDE Components

6 Parts of the Sketch

7 Operators Assignment Operator Equal Sign = : used to assign a value
== : used to compare values if (a == 5)

8 Boolean Operators AND OR NOT && if ((a == 5) && (b == 10)) ||
! if (!isCompleted)

9 Variable Declaration Syntax: Example: type variable_identifier;
type variable_identifier = value; Example: int num; int sum = 0; int i = j = 0; int count = 0; double avg = sum/count ; char ch; char chSep = ','; boolean flag = false;

10 Arduino Function: setup()
This setup() function comes before the loop function Need for all Arduino sketches Syntax: void setup() { }

11 Arduino Function: pinMode(13,OUTPUT)
Digital pins can be used as INPUT, INPUT_PULLUP, or OUTPUT Outputs are declared in setup(). Pin 13 is specified to behave as an output Syntax: pinMode(13, OUTPUT); Declares digital pin #13 as an output

12 Arduino Function: Serial.begin(9600)
Serial communication begins in setup() Syntax: Serial.begin(9600); Declares Serial communication at a baud (bit per second) rate of 9600.

13 Digital I/O Function: digitalWrite(12,HIGH)
Write a HIGH or a LOW value to a digital pin 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW Syntax: digitalWrite(12, HIGH); Sets pin #12 to HIGH

14 LED Program Sets pin 13 to HIGH, makes a one-second-long delay, and sets the pin back to LOW

15 Use Examples_Basics_Blink

16 Blink Example: verify and upload

17 Arduino MEGA Board with Blink Example

18 Digital I/O Function: digitalRead(inPin)
Reads the value from a specified digital pin, either HIGH or LOW Sets pin #13 to the same value as pin #7, declared as an input


Download ppt "Lecture 2-2: Arduino Programming"

Similar presentations


Ads by Google