Arduino Programming For ESD: by MD - Dedarul Hasan
Arduino Programming For ESD: by MD - Dedarul Hasan
ESD
By Md.Dedarul Hasan
Arduino Programming Basic
❖ Introduction
❖ Programming Concept
❖ Digital And Analog Input Receive
❖ Use Of Condition
❖ Use Of Loop
❖ Use Of Array
❖ LCD Display Simulation With Arduino
❖ Servo Motor Simulation With Arduino
❖ Extra Work
❖ Conclusions
Introduction
Microcontroller
A microcontroller can be considered a self-contained system with a processor, memory
and peripherals and can be used as an embedded system.The majority of microcontrollers
in use today are embedded in other machinery, such as automobiles, telephones,
appliances, and peripherals for computer systems.Microcontrollers are designed for
embedded applications, in contrast to the microprocessors used in personal computers or
other general purpose applications consisting of various discrete chips.
❖ central processing unit – ranging from small and simple 4-bit processors to complex 32-
bit or 64-bit processors
❖ volatile memory (RAM) for data storage
❖ ROM, EPROM, EEPROM or Flash memory for program and operating parameter
storage
❖ discrete input and output bits, allowing control or detection of the logic state of an
individual package pin
❖ serial input/output such as serial ports (UARTs)
❖ other serial communications interfaces like I²C, Serial Peripheral Interface and Controller
Area Network for system interconnect
❖ peripherals such as timers, event counters, PWM generators, and watchdog
❖ clock generator – often an oscillator for a quartz timing crystal, resonator or RC circuit
❖ many include analog-to-digital converters, some include digital-to-analog converters
❖ in-circuit programming and in-circuit debugging support
Microprocessor
Microprocessor has only a CPU inside them in one or few Integrated Circuits. Like
microcontrollers it does not have RAM, ROM and other peripherals. They are dependent on
external circuits of peripherals to work. But microprocessors are not made for specific task but they
are required where tasks are complex and tricky like development of software’s, games and other
applications that require high memory and where input and output are not defined. It may be called
heart of a computer system.
Parts of CPU-
❖ ALU
❖ REGISTER
❖ COUNTER
❖ FLAG
❖ BUS
❖ PROGRAM COUNTER
What is Arduino?
Arduino refers to an open-source electronics platform or board and the software used to program for
embedded system. Arduino is designed to make electronics more accessible to artists, designers,
hobbyists and anyone interested in creating interactive objects or environments.
Component Of Arduino :
❖ Microcontroller-ATmega328P
❖ Power (USB / Barrel Jack)
❖ Pins (5V, 3.3V, GND, Analog, Digital, PWM, AREF)
❖ Reset Button.
❖ Power LED Indicator.
❖ TX RX LEDs.
❖ Voltage Regulator.
Different type of Arduino :
❖ Arduino Uno
❖ Arduino Due
❖ Arduino Mega
❖ Arduino Leonardo
❖ LilyPad
❖ Nano
❖ Mini
❖ Mini Pro
❖ BT
Void setup is technically a function that you create at the top of each program. Inside the curly brackets is the
code that you want to run one time as soon as the program starts running. You set things like pinMode in this
section. The loop is another function that Arduino uses as a part of its structure.
Declaration :
Void setup() {
//write code here
}
This is where the bulk of your Arduino sketch is executed. The program starts directly after the opening curly
bracket ( } ), runs until it sees the closing curly bracket ( } ), and jumps back up to the first line in loop() and
starts all over.
Declaration :
Void loop(){
//write code here
}
pinMode() Function :
The pinMode() function is used to configure a specific pin to behave either as an input or an output. It is
possible to enable the internal pull-up resistors with the mode INPUT_PULLUP. Additionally, the INPUT mode
explicitly disables the internal pull-ups.
Declarations :
digitalWrite() Function :
Write a HIGH or a LOW value to a digital pin. If the pin has been configured as an OUTPUT with pinMode() ,
its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH , 0V (ground) for
LOW.
Declaration :
This function use to read the value from a specified digital pin, either HIGH or LOW. Syntax: digitalRead(pin)
Where, pin: the number of the digital pin you want to read (int).
Declaration :
analogWrite () Function :
The analogWrite Arduino command is used to update the status of analog pins and also used to address the
PWM pins on the board. The PWM pins are 8-bit pins, terming that you can set the duty cycle somewhere
between 0 -255.Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying
brightnesses or drive a motor at various speeds.
Declaration :
Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the
Mini and Nano, 16 on the Mega), 10-bit analog to digital converter. This means that it will map input voltages
between 0 and 5 volts into integer values between 0 and 1023.
Declaration :
delay() Function :
The way the delay() function works is pretty simple. It accepts a single integer (or number) argument. This
number represents the time (measured in milliseconds). The program should wait until moving on to the next
line of code when it encounters this function.
Declaration :
We can also use Tinkarcad.com online autodesk software to code & simulations for arduino both.
-https://www.tinkercad.com/dashboard?type=circuits&collection=designs
LED blink Program With Arduino :
LED blinks With Contrast :
Multiple LED Blinks :
Digital And Analog Input Receive
Digital Input Receive :
Analog Input Receive :
Analog Input Delay :
Use Of Condition
condition : each time through the loop, condition is tested; if it's true , the statement block,
and the increment is executed, then the condition is tested again. When the condition
becomes false , the loop ends. increment : executed each time through the loop when
condition is true .
An array is a consecutive group of memory locations that are of the same type. To refer to
a particular location or element in the array, we specify the name of the array and the
position number of the particular element in the array.
All of the methods below are valid ways to create (declare) an array. int myInts[6]; int
myPins[] = {2, 4, 8, 3, 6}; int mySensVals[6] = {2, 4, -8, 3, 2}; char message[6] = "hello";
You can declare an array without initializing it as in myInts. In myPins we declare an
array without explicitly choosing a size.
LED Blink Using Array :
LCD Display Simulation With Arduino
LCD Display Using Arduino :
Servo Motor Simulation With Arduino
A servomotor is a rotary actuator or linear actuator that allows for precise control of
angular or linear position, velocity and acceleration. It consists of a suitable motor coupled
to a sensor for position feedback.
Servo Motor 90 Degree Rotation :
Servo Motor 180 Rotation :
Extra Work : LED Blink Using Push Button
Conclusions :
As a beginner with arduino i am pleased to learn using Tinkarcad.com.Wishing that ,the
feedback by practice i’ll be able to be an expert with that embedded system design.Next, I
shall go for expert and advanced level using arduino.
Thanks