Ardunio Programming and Tinkercad
Ardunio Programming and Tinkercad
ARDUINO IDE
INDEX OF CONTENTS
• Demonstration of setup()
• Demonstration of loop()
• Demonstration of pinMode()
• Demonstration of digitalWrite()
• Demonstration of digitalRead()
• Demonstration of analogWrite()
• Demonstration of analogRead()
Basic Syntaxes
• Setup:
– First and one-time Execution
– Configure Arduino
Syntax:
void setup()
{
………………………….
………………………….
}
Contd…
• Loop:
– After setup() executes
– Infinite Loop
Syntax:
void loop()
{
……………………………….
……………………………….
}
Contd…
• pinMode():
– Intimating Arduino about the peripheral
– Two Arguments, No Return Variable
Syntax:
pinMode(pin, status);
pin: Pin Number
status: INPUT or OUTPUT
Evaluating pinMode()
• Analog Peripheral connected at Pin A2, and it is O/P
– pinMode(A2, OUTPUT);
• Digital Peripheral connected at Pin 3, and it is O/P
– pinMode(3, OUTPUT);
• Analog Peripheral connected at Pin A1, and it is I/P
– pinMode(A1, INPUT);
• Digital Peripheral connected at Pin 0, and it is I/P
– pinMode(0, INPUT);
Note: pinMode() should be written in
setup() as it is configuration bit
GPIO BLOCK
• Input: Analog / Digital
• Output: Analog / Digital
• Read: Input
• Write: Output
digitalWrite()
• Connected Peripheral: Digital
• Status: Output
• Number of Arguments: 2
• Number of Return Variables: 0
Syntax:
digitalWrite(pin, data);
pin: To which pin, you need to write
data: What you need to write (HIGH/LOW)
analogWrite()
• Connected Peripheral: Analog
• Status: Output
• Number of Arguments: 2
• Number of Return Variables: 0
Syntax:
analogWrite(pin, data);
pin: To which pin, you need to write
data: What you need to write (0 to 1023)
digitalRead()
• Connected Peripheral: Digital
• Status: Input
• Number of Arguments: 1
• Number of Return Variables: 1
Syntax:
bit n;
n=digitalRead(pin);
pin: From which pin, you need to read
n value may be 0 or 1
analogRead()
• Connected Peripheral: Analog
• Status: Input
• Number of Arguments: 1
• Number of Return Variables: 1
Syntax:
int n;
n=analogRead(pin);
pin: From which pin, you need to read
n value lies in between 0 to 1023
Arduino
Simulator
• The Arduino simulator is a virtual portrayal of
the circuits of Arduino in the real world.
• We can create many projects using a simulator
without the need for any hardware.
• The Simulator helps beginner and professional
designers to learn, program, and create their
projects without wasting time on collecting
hardware equipment's.
Types of Simulator
There are various simulators available. Some are
available for free, while some require a license to
access the simulators.
Some types of simulators are listed below:
• Autodesk Tinkercad
• Emulator Arduino Simulator
• Autodesk Eagle
• Proteus Simulator
• Virtronics Arduino Simulator
• ArduinoSim
• Here, we are using the Autodesk
Tinkercad Simulator.
1. Open the official website of tinkercad.
URL: https://www.tinkercad.com/
2. Click on the ‘LOG IN' option, if you have an
account in Autodesk. Otherwise, click on the ‘SIGN
UP' option if you don't have an account.
Now, a window will appear, as shown below:
Click on “ + New “ Option on the right to start
designing the Arduino circuit
or
Click on option – “create your first Circuits design”
We are now ready to start with the Autodesk
Tinkercad.
We can start creating our projects.
A window will appear.
We need to drag and drop the desired components
in the project screen. It is shown below:
•Click on the drop list of components and select the 'All' option.
The drop list will appear as:
void loop()
{
digitalWrite(pin,HIGH); // LED ON
}
Program for Blinking an LED:
• Color is black
• The frequency range is 3,300Hz
• Operating Temperature ranges from – 20° C to +60°C
• Operating voltage ranges from 3V to 24V DC
• The sound pressure level is 85dBA or 10cm
• The supply current is below 15mA
Types of Buzzer
A buzzer is available in different types which include the following.
1. Piezoelectric
2. Electromagnetic
3. Mechanical
4. Electromechanical
5. Magnetic
Working Principle
Definition It is a device that detects changes or events in the It is a machine component that moves and controls
environment and transmits that data to another mechanisms.
electronic system.
Basic It converts the physical properties of their It converts the system's electrical signals into
environment into electrical signals for the various physical characteristics for their
system. environments.
Type of Output Electrical signals are generated via sensors. It generates energy in the form of heat or motion.
Source of Input It receives input from the environment. It receives input from the system's output
conditioning unit.
Placement These are placed at a system's input port. These are placed at a system's output port.
Output Generation It produces output for the input conditioning unit It produces output for their environment.
of a system.
Examples Sensors include biosensors, motion sensors, Actuators include electric motors, comb drives,
image sensors, and chemical sensors. stepper motors, and hydraulic cylinders.
Sensors And Actuators in IIoT
• Sensors and actuators are vital pieces of connected technology within
the Industrial Internet of Things (IIoT).
• They are designed to collect and analyze vast amounts of data to help
find ways to streamline operations and improve productivity.
• IIoT systems rely heavily on sensors and actuators to operate.
• Sensors are used to monitor processes and equipment to provide data on
how the systems are functioning.
• Actuators are used within IIoT systems to perform certain mundane or
routine actions on equipment to improve process efficiencies.
• One of the best examples of how sensors and actuators can work
together within IIoT systems is robotic arms in manufacturing plants.
LM35 - Temperature Sensor
LM35 - Temperature Sensor
➢ The LM35 is a low-power, low-cost, high-precision temperature sensor designed
and manufactured by Texas instruments.
➢ This IC provides a voltage output that is linearly proportional to the change in
temperature.
➢ The LM35 sensor is moderately precise and its robust construction makes it
suitable for various environmental conditions. Additionally, you don't need any
external component to calibrate this circuit and it has a typical accuracy of
±0.5°C at room temperature and ±1°C over a full −55°C to +155°C temperature
range. It has an operating voltage of 4V to 30V and consumes 60-uA current
while it's in working state, this also makes it perfect for battery-powered
applications.
➢ There are two disadvantages of this sensor. The first big disadvantage of this
sensor is that it cannot measure negative temperature, for that you have to bias it
with a dual polarity supply. If your project requires negative temperature
measurements, you can opt for a LM36 sensor. The second disadvantage of this
sensor is that it's very sensitive to noise because it outputs data in analog format.
Interfacing LDR
LDR or Light Dependent Resistor or
Photo Resistor or Photocell or
Photoconductor
➢ It is a one type of resistor whose resistance varies
depending on the amount of light falling on its surface.
➢ When the light falls on the resistor, then the resistance
changes.
➢ These resistors are often used in many circuits where it
is required to sense the presence of light.
➢ These resistors have a variety of functions and
resistance.
➢ A typical light dependent resistor has a resistance in the
darkness of 1MOhm, and in the brightness a resistance
of a couple of KOhm
HARDWARE CIRCUITRY
LDR Programs
• Connect LED at Pin A2
• Connect LDR at Pin A0