0% found this document useful (0 votes)
12 views3 pages

Arduino Basics Friendly Guide

This document is a beginner's guide to Arduino programming, covering essential functions such as setup, loop, pin modes, and reading/writing digital and analog values. It includes examples for using comments, variable types, logic keywords, and delays. A full mini example demonstrates how to control an output based on sensor readings.

Uploaded by

markspector90k
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)
12 views3 pages

Arduino Basics Friendly Guide

This document is a beginner's guide to Arduino programming, covering essential functions such as setup, loop, pin modes, and reading/writing digital and analog values. It includes examples for using comments, variable types, logic keywords, and delays. A full mini example demonstrates how to control an output based on sensor readings.

Uploaded by

markspector90k
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/ 3

Arduino Beginner's Friendly Guide

// - Comment
Use this to write notes. Arduino ignores comments.
Example:
// This is a comment
int score = 90; // My score

void setup()
Runs once when Arduino turns on. Use it to set up your pins.
Example:
void setup() {
pinMode(8, OUTPUT); // Set pin 8 as output
}

void loop()
Runs forever. Put your main code here.
Example:
void loop() {
digitalWrite(8, HIGH); // Turn buzzer ON
}

pinMode(pin, mode)
Tells Arduino if pin is input or output.
Example:
pinMode(7, INPUT);
pinMode(8, OUTPUT);

digitalWrite(pin, HIGH or LOW)


Turns something ON or OFF.
Example:
digitalWrite(8, HIGH);
digitalWrite(8, LOW);

digitalRead(pin)
Reads if a pin is HIGH (1) or LOW (0).
Example:
int buttonState = digitalRead(2);

analogRead(pin)
Reads sensor value from 0 to 1023.
Example:
int sensorValue = analogRead(A0);

analogWrite(pin, value)
Sends output like brightness from 0 to 255.
Example:
analogWrite(9, 100);

Variable Types
int - Whole number
float - Number with decimal
char - One letter
bool - true or false

Logic Keywords
== equal to
!= not equal
> greater than
< less than
&& AND
|| OR

Delays & Serial Monitor


delay(1000); // Wait 1 second
Serial.begin(9600);
Serial.println("Hello!");

Full Mini Example


void setup() {
pinMode(8, OUTPUT);
}
void loop() {
int waterLevel = 120;
int dangerLevel = 100;

if (waterLevel > dangerLevel) {


digitalWrite(8, HIGH);
} else {
digitalWrite(8, LOW);
}
}

You might also like