0% found this document useful (0 votes)
4 views25 pages

CT10 Asynchronous 7-02-2025 Einstein

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views25 pages

CT10 Asynchronous 7-02-2025 Einstein

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

7/2/2025

CREATIVE
TECHNOLOGIES 10
INTEGRATED DEVELOPMENT ENVIRONMENT
49

By the end of this lesson, you will be able to:


Identify Arduino syntax
and proper code format
Explain the purpose of
built-in functions
Demonstrate how to
include and use a library in
a sketch

50

1
7/2/2025

What Is the Arduino IDE?


Integrated Development
Environment (IDE):
Editor + Compiler +
Uploader
Runs on Windows,
macOS, Linux
51

IDE
INTERFACE

52

2
7/2/2025

Key Sections of the Arduino IDE


Toolbar: Verify, Upload,
Debug, Select Board,
Serial Plotter, Serial
Monitor, Tab Selection

53

Key Sections of the Arduino IDE


Code Editor: Write your
sketch here

54

3
7/2/2025

Key Sections of the Arduino IDE


Console/Message Area: Shows compile
errors and upload messages

55

Key Sections of the Arduino IDE


Tabs/Menu: File, Edit, Sketch, Tools,
Help

56

4
7/2/2025

SYNTAX

57

Sketch Structure & Code Format


Every sketch has two
mandatory functions:
1. void setup() { … } -
runs once at start
2. void loop() { … } -
repeats forever
58

5
7/2/2025

Sketch Structure & Code Format


Syntax Rules:
Semicolon (;) ends
each statement
Braces ({ }) define
code blocks (groups
the code)
59

Sketch Structure & Code Format


Syntax Rules:
Case Sensitive:
PinMode ≠ pinMode
DigitalWrite ≠ digitalWrite
Comments:
Single line: // this is a comment
Block: /* multiple lines */
60

6
7/2/2025

Declaring Pins & Variables


Digital I/O Pins: numbered 0–13 (Uno)
Analog Input Pins: labeled A0–A5

Use descriptive names


Place declarations at top of sketch
61

FUNCTIONS

62

7
7/2/2025

Built-in Functions

pinMode (pin, mode)

Configure a digital pin as INPUT, OUTPUT, or


INPUT_PULLUP
63

Built-in Functions

pinMode (pin, mode)

Configure a digital pin as INPUT, OUTPUT, or


INPUT_PULLUP
64

8
7/2/2025

Built-in Functions
digitalWrite(pin, value)

Set a digital output pin HIGH (5 V) or LOW (0 V)


65

Built-in Functions

digitalRead(pin)

Read a digital input pin, returning HIGH or LOW

66

9
7/2/2025

Built-in Functions
analogRead(pin)

Read an analog input (0–1023) from pins labeled


A0–A5
67

Built-in Functions
analogWrite(pin, value)

Output a PWM signal (0–255) on supported digital


pins for “analog” control
68

10
7/2/2025

Built-in Functions
delay(milliseconds)

Pause program execution for specified milliseconds


69

Built-in Functions
Serial.begin(baudrate)

Initialize serial communication at given baud rate


(ex. 9600)
70

11
7/2/2025

Built-in Functions
Serial.print(data)

Send text or numbers over serial to the computer


for debugging

71

CODE
EXAMPLES

72

12
7/2/2025

Code Example: Blink LED

73

Code Example: Button State Reporter

74

13
7/2/2025

Code Example: Button State Reporter

75

Code Example: Potentiometer Reader

76

14
7/2/2025

Code Example: Potentiometer Reader

77

LIBRARIES

78

15
7/2/2025

Introducing Libraries
What is a Library?
A collection of
pre-written code to
simplify tasks
Examples: Servo,
LiquidCrystal, Wireless
79

Introducing Libraries

Library Benefits:
Saves development time
Provides tested, reusable functions
80

16
7/2/2025

Using Libraries: Controlling a Servo

81

Using Libraries: LCD

82

17
7/2/2025

Using Libraries: LCD

83

Using Libraries: Wifi

84

18
7/2/2025

Using Libraries: Wifi

85

Using Libraries: Wifi

86

19
7/2/2025

Troubleshooting
& Debugging

87

Troubleshooting & Debugging


Common Errors:
Missing semicolon -
“expected ‘;’ before …”
Unmatched braces -
“expected ‘}’ at end of
input”
Wrong case in function
name
88

20
7/2/2025

Troubleshooting & Debugging


Debug Steps:
Read console error messages
Check line numbers
mentioned
Verify semicolons, braces,
spelling
Use Auto Format (Ctrl+T) to
tidy code
89

PRACTICAL
APPLICATIONS

90

21
7/2/2025

Practical Applications
Home Automation:
automatic night lights,
soil-moisture watering
DIY Robotics: motor
control, sensor feedback
Interactive Art: LED
displays, sound triggers

91

SUMMARY

92

22
7/2/2025

Summary
Core Takeaways:
Syntax and format rules keep
code error-free
Functions perform discrete
tasks; libraries extend
capabilities
The Arduino IDE guides you
from code to hardware
93

ASSESSMENT

94

23
7/2/2025

True or False
1) digitalWrite() is used to read data from a sensor.
2) The Arduino IDE automatically formats your code
with indentation.
3) Libraries allow you to use extra features without
writing all the code yourself.
4) void setup() runs continuously as long as the Arduino
is powered on.
5)Using Serial.begin(9600) starts serial communication
between your Arduino and computer.
95

Matching Type
Function Use
A. Waits for a number of
6. pinMode(pin, mode)
milliseconds
7. analogRead(pin) B. Sets a pin as input or output
8. delay(time) C. Writes a digital value to a pin
9. digitalWrite(pin, val) D. Reads analog value from a sensor
E. Displays text or numbers on the
10. Serial.print(data)
Serial Monitor
96

24
7/2/2025

CREATIVE
TECHNOLOGIES 10
INTEGRATED DEVELOPMENT ENVIRONMENT
97

25

You might also like