INTRODUCTION TO ARDUINO
UNO PROGRAMMING
• Basic Rules
• Variables
• 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)
• Example:
• int ledPin = 13;
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:
• pinMode(13, OUTPUT);
DIGITALWRITE() FUNCTION
• Purpose: Writes HIGH or LOW to a digital pin
• Syntax:
• digitalWrite(pin, value);
• - pin: Arduino pin number
• - value: HIGH or LOW
• Example:
• digitalWrite(13, HIGH);
DELAY() FUNCTION
• Purpose: Pauses the program for a set time (in milliseconds)
• Syntax:
• delay(ms);
• - ms: time in milliseconds
• Example:
• delay(1000);
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?