[go: up one dir, main page]

0% found this document useful (0 votes)
2 views10 pages

Arduino Uno Programming Basics

Uploaded by

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

Arduino Uno Programming Basics

Uploaded by

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

Introduction to Arduino Uno

Programming
• Basic Rules, Variables, and Functions
Basic Programming Rules
• 1. Every Arduino program has void setup() and
void loop()
• 2. Program runs in a linear (top-to-bottom)
fashion
• 3. Use { } curly brackets to define code blocks
• 4. Code is case-sensitive
• 5. Use // to add single-line comments
• 6. End every statement with a semicolon ;
Variables in Arduino
• Definition: Variables are used to store
information to be referenced & manipulated
in a program.

• Declaration Requires:
• - Data Type
• - Variable Name
• - Initial Value (optional)
Types of Variables
• 1. Global Variable
• - Declared outside any function
• - Accessible throughout the program

• 2. Local Variable
• - Declared inside a function
• - Only accessible within that function
pinMode() Function
• Purpose: Sets a pin as input or output

• Syntax:
• pinMode(pin, mode);

• - pin: Arduino pin number


• - mode: INPUT or OUTPUT

• Example:
digitalWrite() Function
• Purpose: Writes HIGH or LOW to a digital pin

• Syntax:
• digitalWrite(pin, value);

• - pin: Arduino pin number


• - value: HIGH or LOW

• Example:
delay() Function
• Purpose: Pauses the program for a set time (in
milliseconds)

• Syntax:
• delay(ms);

• - ms: time in milliseconds

• Example:
Blink Example Code
• void setup() {
• pinMode(LED_BUILTIN, OUTPUT);
• }

• void loop() {
• digitalWrite(LED_BUILTIN, HIGH);
• delay(1000);
• digitalWrite(LED_BUILTIN, LOW);
• delay(1000);
Blink Code Explanation
• - setup() runs once: sets LED as output
• - loop() runs repeatedly:
• - Turns LED on → waits 1 second
• - Turns LED off → waits 1 second
• - This creates a blinking effect
Thank You
• Questions?
• Let's start coding with confidence!

You might also like