0% found this document useful (0 votes)
3 views27 pages

Arduino and Its IDE

The document provides an introduction to Arduino, detailing its components, popular boards, key features, applications, and limitations. It explains the Arduino IDE for programming, including installation steps and basic syntax, as well as the use of TinkerCAD for simulating Arduino projects. Overall, it emphasizes Arduino's versatility in electronics education and project development.

Uploaded by

K SD
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)
3 views27 pages

Arduino and Its IDE

The document provides an introduction to Arduino, detailing its components, popular boards, key features, applications, and limitations. It explains the Arduino IDE for programming, including installation steps and basic syntax, as well as the use of TinkerCAD for simulating Arduino projects. Overall, it emphasizes Arduino's versatility in electronics education and project development.

Uploaded by

K SD
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/ 27

3) Introduction to Arduino

a) Arduino Equipment

 Arduino is an open-source electronics platform based on easy-to-use


hardware and software, designed to make it easy for people to create
interactive projects.
 It consists of both a physical programmable circuit board (often referred to
as a microcontroller) and a piece of software, or Integrated Development
Environment (IDE), that runs on your computer, used to write and upload
code to the board.

Key Components of Arduino:

1. Microcontroller:

 The core of any Arduino board is a microcontroller, typically from


the AVR family (ATmega328 for the Arduino Uno).
 It is a small computer on a single integrated circuit, containing a
processor, memory, and input/output (I/O) peripherals.
 This chip is what executes the code uploaded to the Arduino board.

2. Input and Output Pins (I/O Pins):


 Digital Pins:
 These pins can either be used as inputs or outputs.
 They handle digital signals (HIGH or LOW).
 Depending on the model, an Arduino board can have several
digital I/O pins (Arduino Uno has 14).
 Analog Pins:
 These are used for reading analog sensors or outputting analog
signals using Pulse Width Modulation (PWM).
 The Uno has 6 analog input pins.
 PWM Pins:
 Although digital, PWM pins can mimic an analog output by
varying the width of the digital signal.

1 https://nitw.ac.in/siemens/
 In the Arduino Uno, pins 3, 5, 6, 9, 10, and 11 can be used for
PWM.
3. Power Supply:
 USB Power:
 Arduino boards can be powered via a USB cable connected to
a computer or a power bank.
 External Power Supply:
 A DC power jack allows external power sources, such as
batteries or adapters, typically between 7-12V.
 Voltage Regulators:
 These convert the incoming voltage to a level usable by the
Arduino, usually 5V or 3.3V, depending on the board.
4. Clock:
 Arduino boards contain a crystal oscillator that helps control the
timing of the microcontroller.
 The Arduino Uno operates with a 16 MHz clock, which sets the
timing for executing instructions.
5. Reset Button:
 A physical button on the board allows users to restart the program
that’s running without disconnecting the power.
6. ICSP Header:
 In-Circuit Serial Programming (ICSP) is used to program the
Arduino’s microcontroller directly.
 This is useful for burning the bootloader or when using Arduino in
advanced setups.
7. Serial Communication (TX/RX):
 Arduino boards are capable of communicating with other devices via
serial communication.
 The TX (Transmit) and RX (Receive) pins allow communication
with other hardware, and they can also be used with the built-in USB
to communicate with a computer.

2 https://nitw.ac.in/siemens/
Popular Arduino boards include:

 Arduino Uno:

 One of the most popular boards, it features the ATmega328


microcontroller, 14 digital I/O pins, 6 analog inputs, and a USB
connection.

 Arduino Nano:

 A smaller, breadboard-friendly version of the Uno, but with similar


capabilities.

 Arduino Mega:

 A larger board designed for more complex projects with many I/O
requirements.
 It features 54 digital I/O pins, 16 analog inputs, and uses the
ATmega2560 microcontroller.

 Arduino Due:

 A more powerful board with a 32-bit ARM Cortex-M3 CPU,


running at 84 MHz.
 It is suitable for more demanding applications requiring faster
processing power.

 Arduino Leonardo:

 Similar to the Uno but uses the ATmega32u4 microcontroller. It has


built-in USB communication, allowing it to act as a USB keyboard
or mouse.

 Arduino Pro Mini:

 A minimalistic version of the Nano without a USB interface, used


when a small form factor and lower power consumption are required.

3 https://nitw.ac.in/siemens/
Key Features of Arduino
Open Source:

 Both the Arduino hardware and software are open source.


 This has led to a vast community contributing libraries, tools, and even
alternative boards, ensuring constant innovation and support.

Modularity:

 Arduino boards are modular and can be extended with shields.


 Shields are add-on boards that plug into an Arduino and provide additional
functionalities like WiFi connectivity, motor control, or GPS.

Ease of Use:

 One of the reasons Arduino is so popular is its ease of use.


 The IDE and the programming language are designed to be beginner-friendly.
 The community provides thousands of tutorials, projects, and resources,
which help users get started quickly.

Cross-Platform:

 The Arduino IDE is available for Windows, macOS, and Linux, making it
accessible to developers on all major platforms.

Applications of Arduino:
1. Robotics:

 Arduino is commonly used in robotic projects to control motors,


sensors, and other actuators.
 It can interface with motor drivers, servos, and stepper motors to create
autonomous or manually controlled robots.

4 https://nitw.ac.in/siemens/
2. Home Automation:

 Arduino can be used to control appliances, lights, and security systems


remotely or automatically based on sensor input.
 It can connect to home Wi-Fi networks via modules like ESP8266 or
ESP32.

3. IoT (Internet of Things):

 Arduino boards are widely used for IoT applications.


 Using shields and modules like Wi-Fi, Ethernet, and Bluetooth, it can
connect to the internet and communicate with cloud services, apps, or
other devices.

4. Wearable Devices:

 Boards like the Arduino Nano and Pro Mini are used to create wearable
electronics, often in combination with sensors like accelerometers and
gyroscopes to track movement.

5. Environmental Monitoring:

 Arduino can collect data from sensors measuring temperature,


humidity, pressure, air quality, etc., to monitor environmental
conditions and even upload this data to online platforms for real-time
monitoring.

6. Prototyping:

 Arduino is widely used for rapid prototyping.


 Its ease of use, combined with a large community and support for a
wide range of components, makes it ideal for testing ideas and building
proof-of-concept devices.

5 https://nitw.ac.in/siemens/
Limitations:
1. Limited Processing Power:

 Compared to more advanced microcontrollers or single-board


computers like the Raspberry Pi, Arduino boards have limited
processing power and memory.

2. No Operating System:

 Unlike a Raspberry Pi, Arduino doesn’t run a full operating system.


Each program (sketch) is the only software running on the board.

3. No Built-in Wireless Connectivity:

 While some Arduino boards can be expanded with Wi-Fi or Bluetooth


modules, most models don’t include these features out of the box.

Arduino Shields and Modules


Shields and modules enhance the functionality of Arduino boards. Popular shields
and modules include:

 WiFi/ Ethernet Shields: For internet connectivity.


 Motor Shields: For controlling DC motors, stepper motors, and servos.
 Relay Modules: To control high-power devices like lights and appliances.
 Sensor Modules: Various sensors like temperature, humidity, motion, and
ultrasonic sensors can be easily interfaced.

Advanced Features: Arduino IoT Cloud


 Arduino now offers an IoT Cloud platform, allowing users to connect their
Arduino devices to the cloud.
 This enables remote monitoring, control, and data visualization through
dashboards.

6 https://nitw.ac.in/siemens/
 With integrated features like over-the-air updates and device
management, Arduino IoT Cloud simplifies the creation of connected
projects.

Arduino and Education


 Arduino is widely used in STEM (Science, Technology, Engineering, and
Math) education due to its simplicity and versatility.
 It is frequently employed in schools and universities for teaching concepts
of electronics, programming, and robotics.
 Arduino starter kits are available that provide all the necessary components
for learning and experimenting.

b) Arduino Software (Arduino IDE)

 The Arduino Integrated Development Environment (IDE) is the


platform used to write and upload programs to Arduino boards.
 It supports the Arduino programming language, which is a simplified
version of C/C++.

Key Features of the Arduino IDE:


 Sketch: This is the name given to an Arduino program. A sketch consists
of two primary functions:

 setup(): Initializes variables, sets pin modes, and runs once when the
board is powered up.
 loop(): Contains the main code that runs repeatedly after the setup().

 Serial Monitor:

 This tool in the IDE allows communication between the Arduino and
a computer.
 You can send and receive data, which is useful for debugging.

7 https://nitw.ac.in/siemens/
 Libraries:

 The Arduino ecosystem is rich in libraries that extend functionality,


from controlling motors and sensors to communicating via WiFi or
Bluetooth.

The IDE also allows you to compile code, check for errors, and upload code
directly to the Arduino board via a USB cable.

Below will show you how to install the Arduino IDE on Windows 10.

Step 1: Go to the Arduino.cc Website

Go to the website www.arduino.cc in order to download the software.

Hover over the 'Software' tab and click on 'Downloads'.

8 https://nitw.ac.in/siemens/
Step 2: Click on the Download Link

Scroll down until you see the link that says 'Windows installer' and click on it.

Step 3: Begin the Download

9 https://nitw.ac.in/siemens/
After clicking on the download link you'll be redirected to the donation page,
here you can donate or skip it if you like by clicking on the 'Just download' link.

Step 4: Begin the Installation Process

Open the downloaded file.

A new window will open asking you to agree to the license agreement.

Click on 'I agree' to continue.

10 https://nitw.ac.in/siemens/
Step 5: Select What to Install

Now you'll see all the available options to install the software with.

If you don't know what you need, it is best to keep everything checked as you
can change it later when the installation has finished.

Click on 'Next' to continue.

Step 6: Choose the Installation Path

11 https://nitw.ac.in/siemens/
Now you have to choose the path the software will be installed in.

it is fine to leave it at the configured location but if you want the Arduino IDE
somewhere else installed you can change that here.

Click on 'Install' to begin the installation

Step 7: Finish the Installation

Wait until the installation is finished, it shouldn't take very long.

When the installation is finished you may click on 'close' to end the setup
wizard.

12 https://nitw.ac.in/siemens/
Step 8: Launch the Arduino IDE

The Arduino IDE has now been successfully installed.

To launch the IDE you can click on the Desktop icon that was created for you,
or by searching for it in the start menu.

c) Arduino Programming

Arduino is programmed using a high-level language derived from Wiring, which


in turn is based on C/C++. It is designed to be user-friendly and abstract some of
the complexities of working with hardware.

Basic Syntax:
 Variables: You can define variables for storing data.
 Functions: These are blocks of code that can be reused.
 Control Structures: Arduino uses standard programming control
structures like if, for, and while loops.
 Pin Functions:
o pinMode(pin, mode): Sets whether a pin is an input or output.

13 https://nitw.ac.in/siemens/
o digitalWrite(pin, value): Writes a HIGH or LOW value to a digital
pin.
o digitalRead(pin): Reads a HIGH or LOW value from a digital pin.
o analogRead(pin): Reads an analog value from a pin.
o analogWrite(pin, value): Writes a PWM (Pulse Width Modulation)
signal to a pin.

Arduino Uno
1. Overview:
 The Arduino Uno is one of the most popular microcontroller boards
in the Arduino family, based on the ATmega328P microcontroller.
 It's widely used for developing both simple and complex electronics
projects.
 The board is known for its ease of use, robust community support,
and versatility, making it suitable for hobbyists, students, and
professionals alike.

2. Key Specifications:

 Microcontroller: ATmega328P
 Operating Voltage: 5V
 Input Voltage (recommended): 7-12V
 Input Voltage (limit): 6-20V
 Digital I/O Pins: 14 (of which 6 can provide PWM output)
 Analog Input Pins: 6
 DC Current per I/O Pin: 20 mA
 DC Current for 3.3V Pin: 50 mA
 Flash Memory: 32 KB (ATmega328P), 0.5 KB used by the bootloader
 SRAM: 2 KB (ATmega328P)
 EEPROM: 1 KB (ATmega328P)
 Clock Speed: 16 MHz
 USB Port: Type B for communication with a computer and power
supply.
 Power Supply Pins: Vin, 3.3V, 5V, GND

14 https://nitw.ac.in/siemens/
 Dimensions: 68.6 mm x 53.4 mm
 Weight: Approximately 25g

3. Features:

 USB Connectivity: Allows easy connection to a computer for


programming and debugging.
 PWM (Pulse Width Modulation): Six pins (3, 5, 6, 9, 10, 11) can
generate PWM signals, commonly used to control motors or LED
brightness.
 Analog Inputs: 6 analog input pins (A0–A5) can read voltage signals
from sensors and convert them to digital values.
 ICSP Header: For In-Circuit Serial Programming, allows direct
programming of the microcontroller.
 Reset Button: Resets the program running on the Arduino.
 Built-in LED: A basic indicator LED connected to pin 13 for quick tests
and debugging.

d) Interfacing Sensors and Actuators using Arduino Simulator


(Autodesk TinkerCAD)

 TinkerCAD is an online 3D design and simulation tool widely used for


teaching and prototyping in various fields, including electronics and
embedded systems.
 It's particularly valuable in the context of Arduino Uno because it provides
an intuitive interface for both beginners and advanced users to design,
simulate, and visualize circuits without needing physical hardware.

Overview of TinkerCAD for Arduino


 TinkerCAD’s Circuits module is designed for creating and simulating
electronic circuits.
 It allows users to build projects with virtual Arduino boards, sensors,
actuators, and other components.

15 https://nitw.ac.in/siemens/
 The tool enables users to write code, connect components, and test their
circuits before deploying them to a real Arduino Uno board.

Key Features:
1. Online Platform: TinkerCAD is cloud-based, so no installations are
necessary, and it can be accessed from anywhere with an internet connection.
2. Simulation Environment: You can simulate real-time interaction between the
components and the Arduino Uno board, which is ideal for testing and
troubleshooting.
3. Code Editor with Arduino IDE Integration: TinkerCAD allows you to write,
compile, and run Arduino sketches directly within the platform. It supports both
block-based coding (for beginners) and text-based coding using the Arduino IDE
language (C/C++).
4. Component Library: TinkerCAD offers a vast library of virtual components,
including resistors, LEDs, buttons, sensors, and motors. These can be connected
to the virtual Arduino Uno for simulations.
5. Shared and Collaborative Design: Users can collaborate on projects in real-
time or share their designs with others, which is useful for teamwork and
education.
6. Learning Resources: TinkerCAD provides built-in tutorials, sample circuits,
and learning modules that guide users through the basics of electronics and
Arduino programming.

Steps for Using TinkerCAD with Arduino Uno


1. Creating an Account: Users need to create a free account on the TinkerCAD
website. Once logged in, navigate to the “Circuits” section to start building and
simulating electronic circuits.
2. Adding Components: In the Circuits workspace, users can drag and drop
components from the library onto the design area. For an Arduino Uno project,

16 https://nitw.ac.in/siemens/
this includes selecting the Arduino Uno board and other relevant components
(e.g., LEDs, sensors).
3. Wiring and Circuit Layout: Components can be connected using virtual
wires, following the correct circuit diagram rules. The platform checks for
common issues like short circuits or incorrect wiring.
4. Writing Arduino Code: Once the circuit is built, users can write the Arduino
code. TinkerCAD offers two coding modes:
- Blocks: Visual programming for beginners where users connect blocks that
represent code functions.
- Text Editor: Users can write actual Arduino code in C/C++ using the built-in
editor, similar to the Arduino IDE.
5. Simulation: After the components are wired and the code is written, users can
simulate the project. The simulation allows real-time testing of how the code
interacts with the circuit. The Arduino Uno responds to inputs like button presses
or sensor data, and the output (like LED blinking or motor rotation) is displayed
accordingly.
6. Exporting Code: Once the circuit and code have been successfully simulated,
the Arduino code can be exported to the Arduino IDE for uploading to a physical
Arduino board.

Example Project: Blinking LED with Arduino Uno in TinkerCAD


1. Components:
- Arduino Uno board
- 220-ohm resistor
- LED
- Breadboard
- Jumper wires
2. Steps:
- Place the Arduino Uno and a breadboard in the workspace.

17 https://nitw.ac.in/siemens/
- Connect the LED anode (positive leg) to digital pin 13 of the Arduino using a
jumper wire.
- Connect the LED cathode (negative leg) to a 220-ohm resistor and then to the
ground (GND) pin on the Arduino.
- Write the code in the TinkerCAD editor:
- We are writing the code in cpp

void setup() {
pinMode(13, OUTPUT);
}

void loop() {
digitalWrite(13, HIGH); // Turn the LED on
delay(1000); // Wait for a second
digitalWrite(13, LOW); // Turn the LED off
delay(1000); // Wait for a second
}

- Run the simulation to see the LED blinking on the virtual Arduino board.

Benefits of Using TinkerCAD with Arduino


1. Cost-Effective: No need for physical components. TinkerCAD allows for full
prototyping and simulation of Arduino projects without purchasing hardware.
2. Easy to Use: The drag-and-drop interface is very beginner-friendly. You don’t
need advanced skills to start using Arduino Uno in TinkerCAD.

18 https://nitw.ac.in/siemens/
3. Instant Feedback: The simulation feature helps users understand if their code
and circuit are working properly before transferring the project to a physical
board.
4. Educational Tool: It’s a great platform for teaching and learning electronics
and programming because it offers a safe, virtual environment to experiment
without the risk of damaging components.

Limitations
1. Limited Advanced Components: While TinkerCAD offers a wide array of
components, certain advanced or custom parts may not be available in its library.
2. Performance: Simulating complex or resource-heavy circuits may be slower
than on a physical Arduino board, especially when many components are
involved.
3. No Real-Time Serial Monitor: Although TinkerCAD supports basic serial
monitoring, it lacks some advanced debugging features available in the actual
Arduino IDE.

Conclusion
 TinkerCAD is an invaluable tool for Arduino Uno users, especially
beginners and educators.
 Its cloud-based design environment, combined with real-time simulation
and integrated coding tools, make it easy to build, test, and iterate on
projects.
 While it has some limitations in terms of component availability and
performance for very complex projects, it is an excellent starting point for
learning and prototyping in embedded systems.

19 https://nitw.ac.in/siemens/
Other Programs in TinkerCAD

Program: Connecting a Push Button to turn an LED

Code:
#define led 7
#define button 2
int s;
void setup()
{
pinMode(led,OUTPUT);
pinMode(button,INPUT);
}
void loop()
{
s = digitalRead(button);

20 https://nitw.ac.in/siemens/
if(s == 1)
{
digitalWrite(led,0);
}
else if(s == 0)
{
digitalWrite(led,1);
}
}

Program: Describing the use for Serial Monitor


Code:
void setup()
{
Serial.begin(9600);
Serial.println("Hello NITW!");
delay(1000);
}

void loop()
{
Serial.println("Welcome to IoT webinar");
delay(1000);
}
After uploading the code, open “Serial Monitor” and set the baud rate to 9600
and check the output.

21 https://nitw.ac.in/siemens/
Program: Writing a code to check the Photoresistor (LDR) sensor.

Code:
#define LDR A2

void setup() {
pinMode(LDR, INPUT);
Serial.begin(9600);
}

void loop() {
int a;
a = analogRead(LDR);
Serial.println(a);
}

22 https://nitw.ac.in/siemens/
Program: Writing a code to check the Temperature (LM35) sensor

Code:
#define Temp A2
float celsius = 0;

void setup() {
pinMode(Temp, INPUT);
Serial.begin(9600);
}

void loop() {
celsius = map(((analogRead(Temp) - 20) * 3.04), 0, 1023, -40, 125);
Serial.println(celsius);
}

23 https://nitw.ac.in/siemens/
Program: Writing a code to check the PWM with a Buzzer
Code:
#define Buzzer 6

void setup() {
pinMode(Buzzer,OUTPUT);
}

void loop() {
for(int i = 0; i <= 255; i++)
{
analogWrite(Buzzer,i);
delay(50);
}
}

24 https://nitw.ac.in/siemens/
Program: Write a Code using Ultrasonic Sensor, L293D Motor Driver, Servo
Motor and a DC motor

Code:
#include<Servo.h>
#define trigPin 4
#define echoPin 2
#define servoPin 8
#define in1 11
#define in2 10
#define in3 6
#define in4 5

Servo myservo;

void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(in1, INPUT);

25 https://nitw.ac.in/siemens/
pinMode(in2, INPUT);
pinMode(in3, INPUT);
pinMode(in4, INPUT);
Serial.begin(9600);
myservo.attach(servoPin);
myservo.write(0);
delay(1000);
myservo.write(180);
delay(1000);
myservo.write(0);
delay(1000);
}

void loop()
{
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
digitalWrite(trigPin, HIGH);
delay(10);
digitalWrite(trigPin, LOW);
float duration = pulseIn(echoPin, HIGH);
float distance = duration * 0.034 / 2;
Serial.println(distance);

26 https://nitw.ac.in/siemens/
if(distance <= 40)
{
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, HIGH);
myservo.write(0);
delay(1000);
myservo.write(180);
delay(1000);
myservo.write(0);
delay(1000);
}
}

27 https://nitw.ac.in/siemens/

You might also like