Arduino UNO R3

Arduino Programming Basics

About:



Arduino UNO has 32KB memory, Arduino Mega 256KB, and Nano also 32KB upload memory. The UNO version (best for beginners) includes 14 digital pins (RX, TX, 4 digital, 6 PWM), 6 analog pins, 3 GND pins, and power pins. It also includes SCL (Serial Clock) and SDA (Serial Data). SDA is used for data communication, while SCL is used for synchronization between sender and receiver. SCL is sometimes also called SCK. With these pins (SCL, SDA), you can easily connect and use LCD I2C modules and similar components. Beginners can also use block-based programming tools like "mBlock" instead of Arduino IDE. You can also switch to Arduino IDE coding through the "Arduino C" button in mBlock. There are 3 main Arduino versions and many models for each. For example, the image above shows an Arduino UNO R3 microcontroller. The image below shows a cloned Arduino UNO R3. For beginners, Arduino UNO is recommended. The smallest version is Arduino Nano. The largest is Arduino Mega, which has many pins and large memory capacity, allowing multiple tasks to run at once.

Section 1: Getting Started

First, you need to install the Arduino software. After opening it, if you are a beginner, you will see code that may look confusing at first, but you will understand it over time. This code usually starts with the keyword void. The basic structure is:

Code Example

"void setup" runs once at the start of the program. "void loop" is the main code that runs continuously. You write your code inside the curly brackets {}.

Section 2: Digital Pins


Digital pins on Arduino are used to send or receive HIGH and LOW signals. There are 14 digital pins (including RX, TX, 6 PWM, and 4 standard digital pins). HIGH means 5V output, while LOW means 0V. Digital pins can also read HIGH/LOW signals. The delay() function pauses the program for the specified amount of milliseconds.

Code Example

This program is called LED Blink because the LED turns on and off like blinking. Here is how the code works:


// Comments are added by me
int LEDpin = 13; // We named pin 13 as LEDpin
pinMode(LEDpin, OUTPUT); // Set LEDpin as output
digitalWrite(LEDpin, HIGH); // Turn LED on (5V)
delay(1000); // Wait 1000 ms
digitalWrite(LEDpin, LOW); // Turn LED off
delay(1000); // Wait 1000 ms

NOTE: If you forget the semicolon (;), the code will not work.

NOTE 2: Connect the LED's positive leg to pin 13 and negative leg to GND. The long leg is positive.

Section 3: PWM Pins

PWM (Pulse Width Modulation) pins can output values between 0–255. They allow you to control brightness levels, such as fading LEDs. For example, LED fading gradually increases and decreases brightness using short delays (about 100 ms). Instead of digitalWrite, we use analogWrite:

analogWrite(3, 15) // Sends PWM value 15 to pin 3.

PWM pins are marked with a (~) symbol. Arduino has 6 PWM pins and 6 digital pins. You can also connect sensors like distance sensors and create projects such as a mini parking sensor system using PWM and sensor input.

Section 4: Analog Pins

Analog pins can read values between 0–1024. They are used for sensors that send varying voltage levels. You can read analog values using:

analogRead()

Inside the brackets, you write the pin number like: A{analog pin number} For example, analog sensors can control LED brightness or servo motor movement based on input values.