You are on page 1of 37

List of Programs :

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.

3 Write a program to measure the temperature 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.

6 Explain state change detection (edge detection).

7 Program to detect when a button or button changes from ‘off to on’


and ‘on to off’.

8 Arduino program for LED blink

9 Program to detect a knocking sound.

10 Program to controls the mouse from five pushbuttons on an Arduino Leonardo,


Micro or Due.
Program 1
Write a program to interface the 2 LEDs with arduino with a time
delay of 5000ns.

#include <Scheduler.h>

int led1 = 13;


int led2 = 12;
int led3 = 11;

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);

Serial.println("Led turned off!");

if (c=='1') {

digitalWrite(led3, HIGH);

Serial.println("Led turned on!");


}
}
yield();
}
Program 2
Write a program to measure the distance using ultrasonic sensor
using arduino.

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(

"Distance measurement using Arduino Uno.");


delay(500);

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>

LiquidCrystal lcd(13, 12, 6, 4, 3, 2);

const int temperature = A0; //A0 is the analog pin

const int D = 8; // Vo of LCD is connected to pin 8 of the Arduino

void setup()

lcd.begin(16, 2);

Serial.begin(9600);

pinMode(D, OUTPUT);

void loop()

{
digitalWrite(D,LOW);

int Temp = analogRead(temperature);

float volts = (Temp / 965.0) * 5;

float celcius = (volts - 0.5) * 100;

float fahrenheit = (celcius * 9 / 5 + 32);

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.

Different Memories of Arduino


Strictly speaking, this is specific to the MCU i.e., ATmega328P, used on the Arduino
UNO Board. There are three different memories available in ATmega328P:-

 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:

 ATmega328 Microcontroller: It is a single chip Microcontroller of the ATmel


family. The processor core inside it is of 8-bit. It is a low-cost, low powered, and a
simple microcontroller. The Arduino UNO and Nano models are based on the
ATmega328 Microcontroller.
 Voltage Regulator: The voltage regulator converts the input voltage to 5V. The
primary function of voltage regulator is to regulate the voltage level in the Arduino
board. For any changes in the input voltage of the regulator, the output voltage is
constant and steady.
 GND: Ground pins. The ground pins are used to ground the circuit.
 TXD and RXD: TXD and RXD pins are used for serial communication. The TXD
is used for transmitting the data, and RXD is used for receiving the data. It also
represents the successful flow of data.
 USB Interface: The USB Interface is used to plug-in the USB cable. It allows the
board to connect to the computer. It is essential for the programming of
the Arduino UNO board.
 RESET: It is used to add a Reset button to the connection.
 SCK: It stands for Serial Clock. These are the clock pulses, which are used to
synchronize the transmission of data.
 MISO: It stands for Master Input/ Slave Output. The save line in the MISO pin is
used to send the data to the master.
 VCC: It is the modulated DC supply voltage, which is used to regulate the IC's used
in the connection. It is also called as the primary voltage for IC's present on the
Arduino board. The Vcc voltage value can be negative or positive with respect to the
GND pin.
 Crystal Oscillator: The Crystal oscillator has a frequency of 16MHz, which makes
the Arduino UNO a powerful board.
 ICSP: It stands for In-Circuit Serial Programming. The users can program the
Arduino board's firmware using the ICSP pins.
The program or firmware with the advanced functionalities is received by
microcontroller with the ICSP header consists of 6 pins.

The structure of the ICSP header is shown below:

It is the top view of the ICSP header.

 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()

ss_t **ss = alloc2DArray8(3, 8);

// 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)

disp = new Display(8, 3, ss);


disp->setup();

}
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

 momentary button or switch

 10k ohm resistor

 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’.

const int buttonPin = 2;


const int ledPin = 13;

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.

int LED =13;

void setup ( )

pinMode (LED, OUTPUT);

void loop( )

//Turn ON the LED

digitalWrite (LED, HIGH);

//Wait for 1sec

delay(1000);

// Turn off the LED

digitalRead (LED, LOW);

// Wait for 1sec

delay(1000);

}
Program 9
Program to detect a knocking sound.

const int ledPin = 13;


const int knockSensor = A0;
const int threshold = 100;

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"

const int upButton = 2;


const int downButton = 3;
const int leftButton = 4;
const int rightButton = 5;
const int mouseButton = 6;

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;
}
}

// use the pushbuttons to control the keyboard:


if (digitalRead(upButton) == HIGH)
{
Keyboard.write('u');
}
if (digitalRead(downButton) == HIGH)
{
Keyboard.write('d');
}
if (digitalRead(leftButton) == HIGH)
{
Keyboard.write('l');
}
if (digitalRead(rightButton) == HIGH)
{
Keyboard.write('r');
}
if (digitalRead(mouseButton) == HIGH)
{
Keyboard.write('m');
}
}
List of Programs :

1) India-brief history of Indian constitution, features


of fundamental rights, duties.

2) The fundamental and importance of economics

3) Society-social groups : concepts and types

4) Socialization concept theory

5) Law of return to factors and return to scale


Program 1
History of the Indian Constitution :

In 1600, the British arrived in India as traders in the form of the


East India Company (EIC). Under a Charter granted by Queen
Elizabeth I, the company had the exclusive rights to trading in
India. Initially, they only engaged in trading and were not
motivated by political gains. However, this scenario changed
after their victory in the Battle of Buxar in 1764.
The company which until now was only engaged in trade gained
Diwani rights (rights over revenue) of Bengal, Bihar and Orissa.
This marked the rise of EIC as a territorial force. The company
went on to administer India till 1858 when the British Crown
directly assumed control of India’s affairs in the wake of the
‘Revolt of 1857’. The British government went on to rule India
till its independence on August 15, 1947. India’s independence
necessitated a Constitution for the country. In 1946, the
Constituent Assembly was formed to draft the constitution. The
Indian Constitution came into being on 26th January 1950....
Before the Constitution was formed, the legislations that
governed the functioning of Indian provinces were the Indian
Independence Act of 1947 and the Government of India Act of
1935 which were repealed after the commencement of the
Constitution on 26 January 1950. The constituent assembly was
constituted on November 1946 and the first meeting of the
constituent assembly was held on December 1946. Under the
chairmanship of Dr. BR Ambedkar, the constituent assembly
established a drafting committee to come up with a draft of the
Constitution for India
It took around 11 sessions and 167 days, precisely 2 years 11
months and 18 days to prepare the final draft of the constitution
with a total of 2000 amendments (approx.)...

Features of fundamental rights,duties:

 Fundamental rights are different from ordinary legal


rights in the manner in which they are enforced.
 If a legal right is violated, the aggrieved person
cannot directly approach the SC bypassing the lower
courts.
 He or she should first approach the lower courts.
 Some of the fundamental rights are available to all
citizens while the rest are for all persons (citizens and
foreigners).
 Fundamental rights are not absolute rights.
 They have reasonable restrictions, which means they
are subject to the conditions of state security, public
morality and decency and friendly relations with
foreign countries.
 They are justiciable, implying they are enforceable
by courts. People can approach the SC directly in
case of violation of fundamental rights.
 Fundamental rights can be amended by the
Parliament by a constitutional amendment but only if
the amendment does not alter the basic structure of
the Constitution.
 The Fundamental rights of Indian constitution can be
suspended during a national emergency.
 But, the rights guaranteed under Articles 20 and 21
cannot be suspended.
 The application of fundamental rights can be
restricted in an area that has been placed under
martial law or military rule.
Program 2
The fundamental and importance of
economics:
Economics is a part of social science which is associated with
the study of production, households, distribution, firms,
consumption of goods and services, industries, government,
decision making, and more. It helps to understand how limited
resources can be utilised to satisfy consumers’ desire to obtain
maximum satisfaction.
Economics is classified into two significant parts:
 Microeconomics
 Macroeconomics

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.

2. How to distribute resources in society: To what extent


should we redistribute income in society? Is inequality
necessary to create economic incentives or does inequality
create unnecessary economic and social problems?

3. To what extent should the government intervene in the


economy: A critical divide in economics is the extent to
which the government should intervene in the economy.
Free market economists, like Hayek and Friedman, argue
for limited government intervention and free markets.

4. The principle of opportunity cost: Politicians win


elections by promising more spending and cutting taxes.
This is because lower taxes and more spending is what
voters want to hear. However, an economist will be aware
that everything has an opportunity cost. Spend more on
subsidising free university education, and it means higher
taxes and lower spending elsewhere.

5. Social efficiency: The free market leads to countless


examples of market failure. I feel one of the best uses of
economics is to provide solutions to overcoming market
failure. For example, driving into the centre of town creates
negative externalities such as pollution and congestion.
There is overconsumption. An economist can suggest a tax
on driving into towns to internalise the externality.
6. Knowledge and understanding: One of the principal jobs
for economists is to understand what is happening in the
economy and investigate reasons for poverty,
unemployment and low economic growth. There are many
emotional arguments made about immigration. Economic
studies can try and evaluate the costs and benefits of free
movement of labour.

7. Forecasts: Economic forecasts are more difficult than


understanding the current situation. However, although
forecasts are not always reliable, they can help give
decision-makers an idea of possible outcomes.

8. How to deal with an economic crisis: In the 1930s, the


Wall Street Crash precipitated a significant rise in
unemployment. There was a debate on how to respond.
Many western governments increased taxes, tariffs and
benefits.

9. Evaluation: Economics is not a definitive science like


Maths. Because of many unknown variables, it is
impossible to be definitive about outcomes, but a good
economist will be aware the result depends on different
variables, and there are different potential outcomes.
Program 3
Society-social groups : concepts and
types:

In sociology, a group refers to "any number of people with


similar norms, values, and expectations who interact with one
another on a regular basis."
The crucial aspect is that members of a group must share some
feeling of unity.
This trait separates groups from aggregates, which are simple
collections of individuals, such as people who are on public
transport at the same time.
Social Group is any collection of persons who share common
interest and reason for being together.
Some groups are formed naturally; others are organised for a
particular purpose.
“A group is any collection of human beings who are brought
into social relationships with one another .”
 Types of Social Groups :
 Primary and Secondary Groups
 The term 'primary group' was first used by Charles Horton
Cooley in 1902 to refer to a small group that is characterized
by close-knit cooperation and association between members.
 Primary groups can be very impactful in a person's daily life.
 This is because they perform an expressive, i.e. emotional,
function for us. Both the process of socialization and the
formation of roles and statuses depend heavily on primary
groups.
 A 'secondary group', on the other hand, is a formal,
impersonal group with little social connection or
understanding among its members.
 They serve an instrumental function, meaning that they tend
to be goal-oriented. Secondary groups tend to form in spaces
where people have a shared understanding, but minimal
personal interaction.

 In-groups and Out-groups


 Sometimes, a group's connections to other groups might
give it additional significance for its members.
 This is what forms the basis of in-groups and out-groups.
 Any group or category that people believe they belong to is
considered an in-group. In other words, it includes
everyone who is referred to as "we" or "us."
 The presence of an in-group necessitates the existence of
an out-group, which is a group or category to which
people believe they do not belong. Out-groups are
perceived as "they" or "them."
 In-groups are often marked by a sense of importance
and superiority from those who are not a part of the group,
i.e. out-groups.
 Members of in-groups feel their behaviors, values,
attitudes, etc. are not only better than but also unsuitable for
the out-group.

 Reference Groups
 A 'reference group' is any group people view as a
benchmark for assessing themselves and their behavior.

 By establishing and enforcing morals, norms, and codes of


conduct, reference groups serve a normative purpose.

 Reference groups also serve as a baseline by which


individuals can judge each another, serving as a tool for
comparison.
Program 4
Socialization concept theory

 Socialization is the means by which human infants begin to


acquire the skills necessary to perform as functioning
members of their society.
 “Socialization” is a term used by sociologists, social
psychologists, anthropologists, political scientists, and
educationalists to refer to the lifelong process of inheriting
and disseminating norms, customs, and ideologies,
providing an individual with the skills and habits necessary
for participating within his or her own society.
 Socialization is thus “the means by which social and
cultural continuity are attained.”
 Socialization is the means by which human infants begin to
acquire the skills necessary to perform as a functioning
member of their society and is the most influential learning
process one can experience.
 Unlike other living species, whose behavior is biologically
set, humans need social experiences to learn
their culture and to survive.
 Although cultural variability manifests in the actions,
customs, and behaviors of whole social groups, the most
fundamental expression of
 culture is found at the individual level.
 This expression can only occur after an individual has been
socialized by his or her parents, family, extended family,
and extended social networks.
 The looking-glass self is a social psychological concept,
created by Charles Horton Cooley in self grows out
of society’s interpersonal interactions and the perceptions
of others.
 The term refers to people shaping themselves based on
other people’s perception, leads people to reinforce other
people’s perspectives on them.
Program 5
Law of return to factors and return to scale :

Basis Returns to Factor Returns to Scale

The rise in the total The change in output that


product that results from results from a change in the
increasing just one factor factor inputs
Meaning
while holding the other simultaneously in the same
factors constant is known proportion in the long run is
as Returns to Factor. known as Returns to Scale.

In returns to factor, as the


variable factor keeps on In returns to scale, the
Factor
changing, the ratio of factor proportion does not
Proportion
fixed and variable factors change.
also changes.

The scale of production in


The scale of production in
Scale of case of returns to factor
case of returns to scale
Production does not change. Only the
changes.
production level changes.
Basis Returns to Factor Returns to Scale

Returns to factor applies Returns to scale is


Time
to the short-run concerned with the long-run
Period
production function. production function.

The output of the


The output of the
commodity changes with
Reason for commodity changes with
the change in the marginal
Operation the change in the efficiency
productivity of the
of all factors.
variable factor.

You might also like