Esd Practical
Esd Practical
Esd Practical
1 Write a program to interface the 2 LEDs with arduino with a time delay of
5000ns.
2 Write a program to measure the distance using ultrasonic sensor using arduino.
4 State and explain complete arduino board with its pin configuration.
5 Write a program to interface the LED display with arduino and display message
like name and roll number.
#include <Scheduler.h>
void setup() {
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
Scheduler.startLoop(loop2);
Scheduler.startLoop(loop3);
}
void loop() {
digitalWrite(led1, HIGH);
delay(1000);
digitalWrite(led1, LOW);
delay(1000);
}
void loop2() {
digitalWrite(led2, HIGH);
delay(100);
digitalWrite(led2, LOW);
delay(100);
}
void loop3() {
if (Serial.available()) {
char c = Serial.read();
if (c=='0') {
digitalWrite(led3, LOW);
if (c=='1') {
digitalWrite(led3, HIGH);
long duration;
int distance;
void setup()
{
pinMode(trigPin,
OUTPUT); // Sets the trigPin as an OUTPUT
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
Serial.begin(9600);
Serial.println(
void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(
trigPin,
HIGH); // turn on the Trigger to generate pulse
delayMicroseconds(10);
digitalWrite(trigPin,LOW);
duration = pulseIn(echoPin, HIGH);
distance= duration * 0.0344 / 2; // Expression to calculate
Serial.print("Distance: ");
Serial.print(distance); // Print the output in serial monitor
Serial.println(" cm");
delay(100);
}
Program 3
Write a program to measure the temperature sensor using arduino.
#include <LiquidCrystal.h>
void setup()
lcd.begin(16, 2);
Serial.begin(9600);
pinMode(D, OUTPUT);
void loop()
{
digitalWrite(D,LOW);
Serial.println(fahrenheit);
lcd.setCursor(5, 0);
lcd.print(fahrenheit);
delay(2000);
}
Program 4
State and explain complete arduino board with its pin configuration.
Arduino is an open-source electronics platform based on easy-to-use hardware and
software. Arduino boards are able to read inputs - light on a sensor, a finger on a button,
or a Twitter message - and turn it into an output - activating a motor, turning on an LED,
publishing something online. You can tell your board what to do by sending a set of
instructions to the microcontroller on the board. To do so you use the Arduino
programming language (based on Wiring), and the Arduino Software (IDE), based on
Processing.
Over the years Arduino has been the brain of thousands of projects, from everyday
objects to complex scientific instruments. A worldwide community of makers - students,
hobbyists, artists, programmers, and professionals - has gathered around this open-
source platform, their contributions have added up to an incredible amount of accessible
knowledge that can be of great help to novices and experts alike.
Arduino was born at the Ivrea Interaction Design Institute as an easy tool for fast
prototyping, aimed at students without a background in electronics and programming.
As soon as it reached a wider community, the Arduino board started changing to adapt
to new needs and challenges, differentiating its offer from simple 8-bit boards to
products for IoT applications, wearable, 3D printing, and embedded environments.
32 KB of Flash Memory
2 KB of SRAM
1 KB of EEPROM
0.5 KB of the Flash Memory is used by the bootloader code.
Arduino Pin Description:
SDA: It stands for Serial Data. It is a line used by the slave and master to send and
receive data. It is called as a data line, while SCL is called as a clock line.
SCL: It stands for Serial Clock. It is defined as the line that carries the clock data. It
is used to synchronize the transfer of data between the two devices. The Serial Clock
is generated by the device and it is called as master.
SPI: It stands for Serial Peripheral Interface. It is popularly used by the
microcontrollers to communicate with one or more peripheral devices quickly. It
uses conductors for data receiving, data sending, synchronization, and device
selection (for communication).
MOSI: It stands for Master Output/ Slave Input.The MOSI and SCK are driven by
the Master.
SS: It stands for Slave Select. It is the Slave Select line, which is used by the master.
It acts as the enable line.
I2C: It is the two-wire serial communication protocol. It stands for Inter Integrated
Circuits. The I2C is a serial communication protocol that uses SCL (Serial Clock)
and SDA (Serial Data) to receive and send data between two devices.3.3V and 5V
are the operating voltages of the board.
Program 5
Write a program to interface the LED display with arduino and
display message like name and roll number.
#include <Display.h>
Display disp;
ss_t **ss;
ss_t** createSS()
// first row
ss[0][0] = 48;
ss[0][1] = 46;
ss[0][2] = 49;
ss[0][3] = 47;
ss[0][4] = 45;
ss[0][5] = 43;
ss[0][6] = 41;
ss[0][7] = 39;
// second row
ss[1][0] = 36;
ss[1][1] = 34;
ss[1][2] = 32;
ss[1][3] = 30;
ss[1][4] = 28;
ss[1][5] = 26;
ss[1][6] = 24;
ss[1][7] = 22;
// third row
ss[2][0] = 37;
ss[2][1] = 35;
ss[2][2] = 33;
ss[2][3] = 31;
ss[2][4] = 29;
ss[2][5] = 27;
ss[2][6] = 25;
ss[2][7] = 23;
return ss;
void setup() {
util_setup();
log_setup();
ss = createSS();
// Test display consist of 8x3 LED Modules (3 rows, each one 8 Modules)
}
Program 6
Explain state change detection (edge detection).
Once you've got a pushbutton working, you often want to do some action based on how
many times the button is pushed. To do this, you need to know when the button changes
state from off to on, and count how many times this change of state happens. This is
called state change detection or edge detection. In this tutorial we learn how to check
the state change, we send a message to the Serial Monitor with the relevant information
and we count four state changes to turn on and off an LED.
Hardware Required
Arduino Board
hook-up wires
breadboard
Circuit:
Connect three wires to the board. The first goes from one leg of the pushbutton through
a pull-down resistor (here 10k ohm) to ground. The second goes from the corresponding
leg of the pushbutton to the 5 volt supply. The third connects to a digital I/O pin (here
pin 2) which reads the button's state.
When the pushbutton is open (unpressed) there is no connection between the two legs of
the pushbutton, so the pin is connected to ground (through the pull-down resistor) and
we read a LOW. When the button is closed (pressed), it makes a connection between its
two legs, connecting the pin to voltage, so that we read a HIGH. (The pin is still
connected to ground, but the resistor resists the flow of current, so the path of least
resistance is to +5V.)
If you disconnect the digital I/O pin from everything, the LED may blink erratically.
This is because the input is "floating" - that is, not connected to either voltage or ground.
It will more or less randomly return either HIGH or LOW. That's why you need a pull-
down resistor in the circuit.
Schematic:
Program 7
Program to detect when a button or button changes from ‘off to on’
and ‘on to off’.
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;
void setup()
{
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState != lastButtonState)
{
if (buttonState == HIGH) {
buttonPushCounter++;
Serial.println("on");
Serial.print("number of button pushes: ");
Serial.println(buttonPushCounter);
}
else {
Serial.println("off");
}
delay(50);
}
lastButtonState = buttonState;
if (buttonPushCounter % 4 == 0)
{
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
}
Program 8
Arduino program for LED blink.
void setup ( )
void loop( )
delay(1000);
delay(1000);
}
Program 9
Program to detect a knocking sound.
int sensorReading = 0;
int ledState = LOW;
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
sensorReading = analogRead(knockSensor);
if (sensorReading >= threshold)
{
ledState = !ledState;
digitalWrite(ledPin, ledState);
Serial.println("Knock!");
}
delay(100);
}
Program 10
Program to controls the mouse from five pushbuttons on an Arduino
Leonardo, Micro or Due.
#include "Keyboard.h"
#include "Mouse.h"
void setup()
{
pinMode(upButton, INPUT);
pinMode(downButton, INPUT);
pinMode(leftButton, INPUT);
pinMode(rightButton, INPUT);
pinMode(mouseButton, INPUT);
Serial.begin(9600);
Mouse.begin();
Keyboard.begin();
}
void loop()
{
if (Serial.available() > 0) {
char inChar = Serial.read();
switch (inChar) {
case 'u':
// move mouse up
Mouse.move(0, -40);
break;
case 'd':
// move mouse down
Mouse.move(0, 40);
break;
case 'l':
// move mouse left
Mouse.move(-40, 0);
break;
case 'r':
// move mouse right
Mouse.move(40, 0);
break;
case 'm':
// perform mouse left click
Mouse.click(MOUSE_LEFT);
break;
}
}
Microeconomics
Microeconomics is the yin to the yang that is macroeconomics.
In simple terms, it is the opposite of macroeconomics, as
microeconomics seeks to understand how individuals and
individual companies can influence the economy, and what
drives those economic actors to take the decisions that they do.
Key microeconomics terms that you may encounter include:
The price elasticity of demand;
Asymmetric information; and
Income distribution.
If you’re interested in the study of individuals and their
behaviour, you may also find the relatively new area of
behavioural economics interesting. Figures such as Daniel
Kahneman and Amos Tversky have propelled the field forward,
and essentially argue that individuals don’t act in a
particularly rational way.
Macroeconomics
Macroeconomics is the study of the economy as a whole and
seeks to look at the “big picture” of how global financial
markets and local economies operate. Some of the key
macroeconomics terms you may come across during your
studies include:
The business cycle;
Gross domestic product (GDP);
Inflation and deflation; and
Monetary or fiscal policy
There are other key economic terms within this field, such
as aggregate demand and supply, so the above list is not
exhaustive.
If you find yourself struggling with any of the key
macroeconomics terms, or would like to learn more about this
area of economic study, then it may be a good idea to enlist the
help of a tutor to get you up to speed with the latest
macroeconomic concepts and issues.
Sites such as Superprof can pair you up with tutors that are
happy to work with you, either in an online capacity or in-
person, to help focus your learning efforts on those areas of
economics that you really need help with.
Importance of economics :
1. Dealing with a shortage of raw materials: Economics
provides a mechanism for looking at possible consequences
as we run short of raw materials such as gas and oil.
Reference Groups
A 'reference group' is any group people view as a
benchmark for assessing themselves and their behavior.