Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Arduino_Programming_Notes1

The document provides an overview of Arduino programming, including hardware layout, IDE components, and core programming concepts. It covers input/output operations, timing functions, program structure, variables, and conditional statements. Additionally, it includes example projects demonstrating basic programming techniques.

Uploaded by

XÏX LXÏX
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Arduino_Programming_Notes1

The document provides an overview of Arduino programming, including hardware layout, IDE components, and core programming concepts. It covers input/output operations, timing functions, program structure, variables, and conditional statements. Additionally, it includes example projects demonstrating basic programming techniques.

Uploaded by

XÏX LXÏX
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Arduino Programming Notes

Hardware Layout and Components


- USB Connection: Used for both data transfer and power
- Alternate Power: 9V option available- Pin Configuration:
- Digital I/O: Pins 2-13
- Serial Transfer: Pins 0-1
- Analog Input: Pins 0-5
- Power Pins: 5V, 9V, GND (2 sets)- Additional Components:
- Power Source
- Jumper
- Reset Button

IDE (Integrated Development Environment)


Key Components
- Code Editor
- Compile Button
- Upload to Controller Function
- Text Output (Serial Data)
- Serial Monitor Window

Settings Configuration
1. Serial Port Setup
- Communication via USB-Serial adapter
- Requires proper driver installation
- Found under Tools -> Serial Port
2. Board Selection
- Must select correct board type
- Located under Tools -> Board menu
Core Concepts
INPUT vs OUTPUT
1. Input
- Signals/information entering the board - Examples:
- Buttons
- Switches
- Light Sensors
- Flex Sensors
- Humidity Sensors
- Temperature Sensors
2. Output
- Signals exiting the board - Examples:
- LEDs
- DC motors
- Servo motors
- Piezo buzzers
- Relays
- RGB LEDs

Analog vs Digital
- Microcontrollers are digital devices (ON/OFF, discrete)
- Digital: Binary states (0V or 5V)
- Analog: Can have full range of values
Programming Fundamentals
Digital I/O Operations
1. Pin Mode Configuration pinMode(pin, mode); // Sets pin to INPUT
or OUTPUT
2. Digital Operations digitalRead(pin); // Reads HIGH or LOW
digitalWrite(pin, value); // Writes HIGH or LOW
3. Electronic Specifications
- Output pins: 40mA current capacity
- Input pins with HIGH: 20KOhm pull-up installed

Timing Functions
- delay(ms): Pauses for milliseconds
- delayMicroseconds(us): Pauses for microseconds

Program Structure
1. Basic Sections: void setup() {
// Setup motors, sensors, etc.
}
void loop() {
// Get information from sensors
// Send commands to motors
}
2. Setup Section
- Used for I/O assignments
- Device configuration (OUTPUT/INPUT) - Uses pinMode
command pinMode(9, OUTPUT); // Example
3. Loop Section void loop() {
digitalWrite(9, HIGH);
delay(1000); digitalWrite(9,
LOW); delay(1000);
}

Variables
- Act as temporary storage ("buckets") - Declaration Format: int val = 5;
// Type, name, assignment, value
Variable Types
- 8-bit: byte, char
- 16-bit: int, unsigned int
- 32-bit: long, unsigned long, float

Variable Scope
- Global
- Function-level

Comments
// Single line comment
/* Multi-line comment
block */
Programming Concepts
Digital Input
- Uses pins 0-13 (0 & 1 also used for programming) - Configuration:
pinMode(pinNumber, INPUT); // Setup int buttonState =
digitalRead(pinNumber); // Reading

Digital Sensors
- Binary states only (ON/OFF)
- HIGH ~ 5V (Uno)
- LOW = 0V

Conditional Statements
void loop() { int buttonState = digitalRead(5);
if (buttonState == LOW) {
// action for LOW
} else {
// action for HIGH
}}

Boolean Operators
- == : Equal to
- != : Not equal to
- > : Greater than
- >= : Greater than or equal
- < : Less than
- <= : Less than or equal
Example Projects
Project 1: Basic Blink
Pseudocode Flow:
1. Turn LED ON
2. Wait
3. Turn LED OFF
4. Wait
5. Repeat

Project 2: Button-Controlled Blink


Pseudocode Flow:
1. Turn LED ON when button is ON
2. Wait
3. Turn LED OFF when button is OFF
4. Wait
5. Repeat

You might also like