This slides has complete code with respected circuit of projects. It contains Detail information required before starting a arduino project.All the projects are compiled, debugged and simulated on proteus. If you need arduino library for proteus then please visit this link: https://www.facebook.com/cots2013
Arduino is an open-source project that created microcontroller-based kits for building digital devices and interactive objects that can sense and control physical devices.
An introduction to the Arduino microcontroller for the Washington, DC Kids & Technology Meetup. Processing software, Arduino hardware were discussed. Several Arduino projects were demonstrated. Resources are posted here:
https://www.evernote.com/shard/s89/sh/6fd6ce79-c0b2-495e-b6f8-a4c4335cd284/9b1d07121e9f4b89106bcfcba6463bdf
Arduino is an open-source project that created microcontroller-based kits for building digital devices and interactive objects that can sense and control physical devices.
An introduction to the Arduino microcontroller for the Washington, DC Kids & Technology Meetup. Processing software, Arduino hardware were discussed. Several Arduino projects were demonstrated. Resources are posted here:
https://www.evernote.com/shard/s89/sh/6fd6ce79-c0b2-495e-b6f8-a4c4335cd284/9b1d07121e9f4b89106bcfcba6463bdf
Logic gate tester for IC's ( Digital Electronics and Logic deisgn EE3114 )Jikrul Sayeed
Name of the project: Logic Gate Tester for DELD EE3114
1.1Abstract:
Performing various types of logic operation we need to use logic gates and in integrated circuit there are more than one gates fabricated in a single IC. Before using gates for various purposes we need to check logic gates including all logic
combination considering in Binary (Logic 1 & 0) needs to implement. It is a time consuming task to check all the input combinations, thus the sole purpose of this project to make it automatic to check all the logic .
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009Eoin Brazil
CS4062 Masters in Interactive Media - Fourth Arduino Lecture - March 18th 2009 - University of Limerick. This lecture presents a short review and introduction to programming concepts relevant to Arduino. This was aimed at a digital media / music technology masters student audience.
Intro to Arduino Class taught at CRASHspace by Quin (Qtechknow). Originally taught on August 11, 2012 at Crashspace, in LA. This revision patches the diagrams and fixes the code! Thanks to SparkFun who shared all of their original slides with me!
Getting started with Arduino Programming can be daunting. These are slides I used in my classes which introduced programming concepts to non-engineers, non-programmers, but totally people who wanted to learn more about electronics.
Project for the WHD global 2017 hackathon with Arduino Intel Edison and Intel IoT analytics.
The aim of the project is use the Intel IoT platform hosted in 1&1 cloud servers to make a demo of how easy you can connect any “thing” like solar power panels to Internet.
An introduction to Arduino micro-controller platform and C programming meant for the board. Introduction to debugging and hardware specification and limitations of the board.
An Arduino guide for beginners.
Topics covered: what is it, use cases examples, microcontrollers vs microprocessors, pins and connections, IDEs, demos.
Blinking LED's Animation Connected to a PortRihab Rahman
The presentation is about the implementation of LED's animation using Arduino UNO. It also contains the program to burn in the Arduino for implementation.
This article should help you to do basic setup of Arduino Controller in Proteus, programming and simulation of Arduino in Proteus. In this article I have tried to make it simple to use LCD with Arduino with some simulation and programming. As compared to my previous tutorial I am using here Arduino Controller IC instead of Arduino Uno Board.
Logic gate tester for IC's ( Digital Electronics and Logic deisgn EE3114 )Jikrul Sayeed
Name of the project: Logic Gate Tester for DELD EE3114
1.1Abstract:
Performing various types of logic operation we need to use logic gates and in integrated circuit there are more than one gates fabricated in a single IC. Before using gates for various purposes we need to check logic gates including all logic
combination considering in Binary (Logic 1 & 0) needs to implement. It is a time consuming task to check all the input combinations, thus the sole purpose of this project to make it automatic to check all the logic .
Arduino Lecture 4 - Interactive Media CS4062 Semester 2 2009Eoin Brazil
CS4062 Masters in Interactive Media - Fourth Arduino Lecture - March 18th 2009 - University of Limerick. This lecture presents a short review and introduction to programming concepts relevant to Arduino. This was aimed at a digital media / music technology masters student audience.
Intro to Arduino Class taught at CRASHspace by Quin (Qtechknow). Originally taught on August 11, 2012 at Crashspace, in LA. This revision patches the diagrams and fixes the code! Thanks to SparkFun who shared all of their original slides with me!
Getting started with Arduino Programming can be daunting. These are slides I used in my classes which introduced programming concepts to non-engineers, non-programmers, but totally people who wanted to learn more about electronics.
Project for the WHD global 2017 hackathon with Arduino Intel Edison and Intel IoT analytics.
The aim of the project is use the Intel IoT platform hosted in 1&1 cloud servers to make a demo of how easy you can connect any “thing” like solar power panels to Internet.
An introduction to Arduino micro-controller platform and C programming meant for the board. Introduction to debugging and hardware specification and limitations of the board.
An Arduino guide for beginners.
Topics covered: what is it, use cases examples, microcontrollers vs microprocessors, pins and connections, IDEs, demos.
Blinking LED's Animation Connected to a PortRihab Rahman
The presentation is about the implementation of LED's animation using Arduino UNO. It also contains the program to burn in the Arduino for implementation.
This article should help you to do basic setup of Arduino Controller in Proteus, programming and simulation of Arduino in Proteus. In this article I have tried to make it simple to use LCD with Arduino with some simulation and programming. As compared to my previous tutorial I am using here Arduino Controller IC instead of Arduino Uno Board.
Your Future HTML: The Evolution of Site Design with Web ComponentsKen Tabor
This talk is dedicated to helping you understand how you can easily build reusable pieces of user interface while assembling your overall experience. Specifically the emerging technology of web components is introduced as the way you can package your HTML, CSS, and JavaScript to produce drop-in solutions. It’s like building UI elements and widget controls for the web.
By using this tactic to architect your sites you’ll reduce time, and increase quality, of the work your development team produces. See how designers and developers will use the deep functionality web components offer. Make custom HTML tags backed by the necessary markup, style, and code. This unique bundle mixes presentation with behavior creating rich and flexible micro-interactions.
I’ll review how the popular browser makers are implementing this emerging technology on desktop and mobile. I’ll introduce Google’s Polymer library as a way you can use web components now while platform owners are in the process of supporting the proposed standard.
Keynote presented at SDD (12th May 2015)
Somewhere in the heart of a development process, essential to the very being of a product's existence, are the people who write, consider and wrestle with code. What motivates and demotivates them? What are the intellectual challenges and rewards? What are the skills they have and need and cognitive biases and environment they work with and against?
This talk by the editor of 97 Things Every Programmer Should Know considers the act of programming and those who do it and want to get better at it, from the perspective of development process to craft, from architecture to code.
Designed keeping in mind the latest technology on a single board. It is really easy to design, experiment with, and test circuitry without soldering. Students can explore a wide variety of electronic concepts simply by placing components on to the breadboard. It is very useful in electronics laboratories for performing IoT experiments. It is also useful to build and test circuits as well as making projects related to IoT integrating with the cloud platform. visit https://researchdesignlab.com/esp32-development-board-trainer-kit.html for more details
At the end of the topic you should be able to:
1. Explain the importance of platform based development
2. Use looping, delay and conditioning concepts in developing a program on Arduino environment.
Arduino is an open- source computer hardware and software company, project and user community that designs and manufactures microcontroller-based kits for building systems consisting of digital devices, interactive objects that can sense and control in the physical world.
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.
1. Explaining the importance of platform based development
2. Understanding The importance of NodeMCU and demonstrate its interfacing with various devices and sensors.
Similar to Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal (20)
ACEP Magazine edition 4th launched on 05.06.2024Rahul
This document provides information about the third edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
Low power architecture of logic gates using adiabatic techniquesnooriasukmaningtyas
The growing significance of portable systems to limit power consumption in ultra-large-scale-integration chips of very high density, has recently led to rapid and inventive progresses in low-power design. The most effective technique is adiabatic logic circuit design in energy-efficient hardware. This paper presents two adiabatic approaches for the design of low power circuits, modified positive feedback adiabatic logic (modified PFAL) and the other is direct current diode based positive feedback adiabatic logic (DC-DB PFAL). Logic gates are the preliminary components in any digital circuit design. By improving the performance of basic gates, one can improvise the whole system performance. In this paper proposed circuit design of the low power architecture of OR/NOR, AND/NAND, and XOR/XNOR gates are presented using the said approaches and their results are analyzed for powerdissipation, delay, power-delay-product and rise time and compared with the other adiabatic techniques along with the conventional complementary metal oxide semiconductor (CMOS) designs reported in the literature. It has been found that the designs with DC-DB PFAL technique outperform with the percentage improvement of 65% for NOR gate and 7% for NAND gate and 34% for XNOR gate over the modified PFAL techniques at 10 MHz respectively.
Water billing management system project report.pdfKamal Acharya
Our project entitled “Water Billing Management System” aims is to generate Water bill with all the charges and penalty. Manual system that is employed is extremely laborious and quite inadequate. It only makes the process more difficult and hard.
The aim of our project is to develop a system that is meant to partially computerize the work performed in the Water Board like generating monthly Water bill, record of consuming unit of water, store record of the customer and previous unpaid record.
We used HTML/PHP as front end and MYSQL as back end for developing our project. HTML is primarily a visual design environment. We can create a android application by designing the form and that make up the user interface. Adding android application code to the form and the objects such as buttons and text boxes on them and adding any required support code in additional modular.
MySQL is free open source database that facilitates the effective management of the databases by connecting them to the software. It is a stable ,reliable and the powerful solution with the advanced features and advantages which are as follows: Data Security.MySQL is free open source database that facilitates the effective management of the databases by connecting them to the software.
2. TOPICS:
1. Introduction to Arduino
2. Arduino Boards
3. Integrated Development Environment-IDE
4. What it can do?
5. Why arduino?
6. Arduino Uno complete description
7. Projects
bishalbtry@gmail.com 2
3. 1. Introduction:
• First Arduino was introduced in 2005
• Arduino is an open-source prototyping platform
• It is based on easy-to-use hardware and software
• Microcontroller board design manufactured
primarily by Smart Projects in Italy
bishalbtry@gmail.com 3
Open Source
Hardware
6. 3. Integrated Development
Environment(IDE):
•IDE a cross-platform application written in Java
• Designed to introduce programming to artists and
other newcomers unfamiliar with software development
• Code editor with features such as:
i. syntax highlighting
ii. brace matching
iii. automatic indentation
• Compiling and uploading programs to the board with
a single click
• A program or code written for Arduino is called a
"sketch”
• Arduino programs are written in C or C++
bishalbtry@gmail.com 6
7. 3. IDE cont…
• The Arduino IDE comes with a software
library called "Wiring”
• Two functions to make an executable cyclic
executive program:
•setup(): function run once at the start of a
program that can initialize settings
•loop(): function called repeatedly until the
board powers off
bishalbtry@gmail.com 7
8. 3. IDE cont…
Functions in Setup()
1. pinMode(13,OUTPUT)://makes pin 13 as output pin
2. pinMode(8, INPUT);//makes pin 8 as input pin
3. Serial.begin(9600) ;//starts serial communication
with Baudrate 9600
Functions in loop()
• 1. digitalWrite(13, HIGH): makes pin 13 high ie pin13=ON;
• 2. delay(500) : delays system by 500 ms.
• 3. analogRead() : Reads analog value
• 4. analogWrite() : writes anlog value(PWM)
• 5. Serial.print() : Prints at serial monitor
• 6. Serial.println() : prints at serial monitor with line break
bishalbtry@gmail.com 8
9. 3. IDE cont…
bishalbtry@gmail.com 9
1.Verify
2.Upload
3.NEW
4.Open :Library,
example
5.Save
7.Message Panel
6.Code Panel
*Port connected to
IDE/Arduino board
*Tool: port setting, board
selection
*Serial
Monitor
10. 4. What it can do?
• Sensors ( to sense stuff )
– Push buttons*, touch pads, tilt switches.
– Variable resistors* (eg. volume knob / sliders)
– Photoresistors* (sensing light levels)
– Thermistors* (temperature)
– Ultrasound (proximity range finder)
• Actuators ( to do stuff )
– Lights, LED’s*
– Motors*
– Speakers
– Displays (LCD)*
bishalbtry@gmail.com 10
11. 5.Why Arduino?
• Simplify working with microcontr
• Inexpensive compare to other u-controller
platform
• Cross platform
• Simple, clear programming environment
• Simple, clear programming environment
• Open source and extensible hardware
bishalbtry@gmail.com 11
12. 6.Arduino Uno Description:
bishalbtry@gmail.com 12
Digital output
~: PWM.
1,0: Serial port Tx
and Rx
In circuit Serial
programming
Atmel
MicroController
Analog input.
Power out and In
USB port for
power or
programming
12v Power
input
13 pin LED
POWER
on/off LED
15. 7. Projects Idea:
1. LED Blink program
2. LED Fading
3. Variable Resistor controlled LED Blink
4. Variable Resistor controlled LED Intensity
5. LCD Interface
6. Keyboard Interface
bishalbtry@gmail.com 15
16. 7. Projects Idea cont…
7. Digital thermometer
8. Motor control via Button
9. Variable Resistor Controlled Servo Motor
10. Ultra Sonic Sensor Interface for Distance
calculation
bishalbtry@gmail.com 16
17. 1. LED BLINK
// the setup function runs once when you press reset or power the
board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(13 LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
}
bishalbtry@gmail.com 17
19. 2.LED FADING:
int ledPin = 9; // LED connected to digital pin 9
void setup() {
pinMode(ledPin, OUTPUT); // nothing happens in setup
}
void loop() {
// fade in from min to max in increments of 5 points:
for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
bishalbtry@gmail.com 19
20. 2.LED FADING cont….
}
// fade out from max to min in increments of 5 points:
for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5)
{
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}
bishalbtry@gmail.com 20
23. 3.Variable resistor controlled
LED BLINK cont..
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(lsensorPin, INPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
digitalWrite(ledPin, HIGH);
delay(sensorValue);
digitalWrite(ledPin, LOW);
delay(sensorValue);
}
bishalbtry@gmail.com 23
24. 4. Variable resistor controlled
LED Intensity
Do Yourself……..
IDEA to program this:
1. Read variable resistor value assign it to ‘C’
2. Convert this ‘C’ value so that you supply that
amount voltage to output pin
3. write this value to PWM pin using
analogWrite() function
bishalbtry@gmail.com 24
34. 8. Digital thermometer:
CODE:
#include <LiquidCrystal.h>
LiquidCrystal lcd(4, 5, 6, 7, 8, 9);
int sensorPin = A0; //analog pin location
void setup()
{
Serial.begin(9600); //Start the serial connection with the computer
lcd.begin(16,2); //Must be defined or it goes to 16X1
lcd.clear(); // Starts with a clean screen
}
bishalbtry@gmail.com 34
35. 8. Digital thermometer:
CODE cont..
void loop()
{
//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);
// converting that reading to voltage, for 3.3v arduino use 3.3
float voltage = reading * 5.0;
voltage /= 1024.0;
// now print out the temperature (voltage-0.5)
float temperatureC = (voltage ) * 100 ; //converting from 10 mv per
degree wit 500 mV offset
//to degrees ((voltage - 500mV) times 100)
bishalbtry@gmail.com 35
36. 8. Digital thermometer:
CODE cont..
lcd.setCursor(0,0);
lcd.print(temperatureC);
lcd.println(" Celsius "); //Shows reading on LCD
// now convert to Fahrenheit
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
lcd.setCursor(0,1);
lcd.print(temperatureF);
lcd.println(" Fahrenheit"); //Shows reading on LCD
delay(500); //Update every 5 seconds, the value is
measured in milliseconds )
}
bishalbtry@gmail.com 36
37. 9. Motor Control:
Requirements:
1. Keyboard interface idea
2. Motor interface with digital o/p pin
3. Condition checking process in program
if…else, switch(), OR anything….
bishalbtry@gmail.com 37
43. 10. Controlling Servo motor:
Requirements:
1. Potentiometer interface
2. Motor interface
3. Variable data from POT applying to motor
interface pin
4. Code on IDE: File>>Example>>servo>>knob
OR follow the note code
bishalbtry@gmail.com 43
Arduino is an open-source computer hardware and software company, project and user community that designs and manufacturesmicrocontroller-based kits for building digital devices and interactive objects that can sense and control the physical world.[1]
The project is based on a family of microcontroller board designs manufactured primarily by SmartProjects in Italy,[2] and also by several other vendors, using various 8-bit Atmel AVR microcontrollers or 32-bit Atmel ARM processors. These systems provide sets of digital and analog I/O pins that can be interfaced to various expansion boards ("shields") and other circuits. The boards feature serial communications interfaces, including USB on some models, for loading programs from personal computers. For programming the microcontrollers, the Arduino platform provides an integrated development environment (IDE) based on the Processing project, which includes support for C,C++ and Java programming languages.
The first Arduino was introduced in 2005, aiming to provide an inexpensive and easy way for novices and professionals to create devices that interact with their environment using sensors and actuators. Common examples of such devices intended for beginner hobbyists include simple robots, thermostats, and motion detectors.
The Arduino integrated development environment (IDE) is a cross-platform application written in Java, and derives from the IDE for the Processing programming language and the Wiring projects. It is designed to introduce programming to artists and other newcomers unfamiliar with software development. It includes a code editor with features such as syntax highlighting, brace matching, and automatic indentation, and is also capable of compiling and uploading programs to the board with a single click. A program or code written for Arduino is called a "sketch".[18]
Arduino programs are written in C or C++. The Arduino IDE comes with a software library called "Wiring" from the original Wiring project, which makes many common input/output operations much easier. The users need only to define two functions to make an executable cyclic executive program:
setup(): a function run once at the start of a program that can initialize settings
loop(): a function called repeatedly until the board powers off
There are many other microcontrollers and microcontroller platforms available for physical computing. Parallax Basic Stamp, Netmedia's BX-24, Phidgets, MIT's Handyboard, and many others offer similar functionality. All of these tools take the messy details of microcontroller programming and wrap it up in an easy-to-use package. Arduino also simplifies the process of working with microcontrollers, but it offers some advantage for teachers, students, and interested amateurs over other systems:
Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller platforms. The least expensive version of the Arduino module can be assembled by hand, and even the pre-assembled Arduino modules cost less than $50
Cross-platform - The Arduino software runs on Windows, Macintosh OSX, and Linux operating systems. Most microcontroller systems are limited to Windows.
Simple, clear programming environment - The Arduino programming environment is easy-to-use for beginners, yet flexible enough for advanced users to take advantage of as well. For teachers, it's conveniently based on the Processing programming environment, so students learning to program in that environment will be familiar with the look and feel of Arduino
Open source and extensible software- The Arduino software is published as open source tools, available for extension by experienced programmers. The language can be expanded through C++ libraries, and people wanting to understand the technical details can make the leap from Arduino to the AVR C programming language on which it's based. Similarly, you can add AVR-C code directly into your Arduino programs if you want to.
Open source and extensible hardware - The Arduino is based on Atmel's ATMEGA8 and ATMEGA168 microcontrollers. The plans for the modules are published under a Creative Commons license, so experienced circuit designers can make their own version of the module, extending it and improving it. Even relatively inexperienced users can build the breadboard version of the module in order to understand how it works and save money.
The fading effect can not be detected on LED, so use Oscilloscope at that pin 9, so that you can see the varying pulse width on it. This simulates thae fading effect.
Make sure that the used variable resistor in proteus is POT-HG , and you can also change the value of POT , by just clicking on the “1k” written text of it.
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
}
LCD we use for this interface is LM016L on proteus.
Follow the pin connection , this is shown by brown color text
We must be clear about the second command , here 4 pin is connected to RS pin of LCD and 5 to Enable and so on…
4x3 Keyboard work on the principle of row or column scan method
Follow the pin connection ,
#include <LiquidCrystal.h>
LiquidCrystal lcd(4, 5, 6, 7, 8, 9);
int sensorPin = A0; //analog pin location
void setup()
{
Serial.begin(9600); //Start the serial connection with the computer
lcd.begin(16,2); //Must be defined or it goes to 16X1
lcd.clear(); // Starts with a clean screen
}
void loop()
{
//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);
// converting that reading to voltage, for 3.3v arduino use 3.3
float voltage = reading * 5.0;
voltage /= 1024.0;
// now print out the temperature (voltage-0.5)
float temperatureC = (voltage ) * 100 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((voltage - 500mV) times 100)
lcd.setCursor(0,0);
lcd.print(temperatureC);
lcd.println(" Celsius "); //Shows reading on LCD
// now convert to Fahrenheit
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
lcd.setCursor(0,1);
lcd.print(temperatureF);
lcd.println(" Fahrenheit"); //Shows reading on LCD
delay(500); //Update every 5 seconds, the value is measured in milliseconds )
}
const int motorR = 13; //right direction motion assign pin
const int motorRB = 12;//right direction backward motion assign pin
const int motorL = 11; //left direction motion assign pin
const int motorLB = 10;//left direction backward motion assign pin
#include <Keypad.h>
const byte ROWS = 2; //2 rows
const byte COLS = 2;//2 column
char keys[ROWS][COLS] = {
{'1','2'},
{'3','4'},
};
byte rowPins[ROWS] = {5, 4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7};// to coloumn pinout
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup() {
// initialize the LED pin as an output:
pinMode(motorR, OUTPUT);
pinMode(motorRB, OUTPUT);
pinMode(motorL, OUTPUT);
pinMode(motorLB, OUTPUT);
pinMode(9, OUTPUT);
pinMode(6, OUTPUT);
// initialize the pushbutton pin as an input:
keypad.setHoldTime(500);
}
void loop() {
char key = keypad.getKey();
if(key)
{
switch(key)
{
case ('1'):
right();
break;
case ('2'):
left();
break;
case ('3'):
forward();
break;
case ('4'):
backward();
break;
default:
stopp();
}
}
}
void right()
{ digitalWrite(9,HIGH);
digitalWrite(6,LOW);
digitalWrite(motorR,HIGH);
digitalWrite(motorRB,LOW);
delay(300);
digitalWrite(motorR,HIGH);
digitalWrite(motorRB,HIGH);
}
void left()
{ digitalWrite(6,HIGH);
digitalWrite(9,LOW);
digitalWrite(motorL,HIGH);
digitalWrite(motorLB,LOW);
delay(300);
digitalWrite(motorL,HIGH);
digitalWrite(motorLB,HIGH);
}
void forward()
{ digitalWrite(9,HIGH);
digitalWrite(6,HIGH);
digitalWrite(motorR,HIGH);
digitalWrite(motorRB,LOW);
digitalWrite(motorL,HIGH);
digitalWrite(motorLB,LOW);
delay(300);
digitalWrite(motorL,HIGH);
digitalWrite(motorLB,HIGH);
digitalWrite(motorR,HIGH);
digitalWrite(motorRB,HIGH);
}
void backward()
{ digitalWrite(9,HIGH);
digitalWrite(6,HIGH);
digitalWrite(motorR,LOW);
digitalWrite(motorRB,HIGH);
digitalWrite(motorL,LOW);
digitalWrite(motorLB,HIGH);
delay(300);
digitalWrite(motorL,HIGH);
digitalWrite(motorLB,HIGH);
digitalWrite(motorR,HIGH);
digitalWrite(motorRB,HIGH);
}
void stopp()
{ digitalWrite(9,HIGH);
digitalWrite(6,HIGH);
digitalWrite(motorL,HIGH);
digitalWrite(motorLB,HIGH);
digitalWrite(motorR,HIGH);
digitalWrite(motorRB,HIGH);
}
CODE : #include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
What is an Ultrasonic Sensor?
Ultrasonic Sensor is a simple sensor used for measuring the distance between sensor itself and any obstacle in front.
The sensor has a transmitter and a receiver on it.
I am gonna use HC-SR04 ultrasonic sensor for this project.
This sensor consists of four pins, which are:
Vcc (+5V)
Trig (Trigger)
Echo
GND
Trigger pin is an output pin while the Echo pin is an input pin, we will discuss them in Working section in detail.
Moreover, it requires +5V to start operating.
It is normally used to detect objects in front of it or to measure the distance between different objects.
Working of Ultrasonic Sensor
Its working is quite simple, as discussed above, it has a trigger and an echo pin.
A signal of +5V is sent over to Trigger pin for around 10 microseconds in order to trigger the sensor.
When ultrasonic sensor gets a trigger signal on its trigger pin then it emits an ultrasonic signal from the transmitter.
This ultrasonic senor, then goes out and reflected back after hitting some object in front.
This reflected ultrasonic signal is then captured by the receiver of ultrasonic sensor.
As the sensor gets this reflected signal, it automatically make the Echo pin high.
The time for which the Echo pin will remain HIGH, depends on the reflected signal.
What we need to do is, we need to read this time for which the echo pin is high, which we are gonna do in our next section.
Interfacing of Ultrasonic Sensor With Arduino
Now we have seen the working of Ultrasonic sensor, so we have some idea what we need to do in order to get the values from it.
First of all, we need to generate a signal of 10 microsecond and then send it over to trigger pin.
After sending the trigger pin we then need to read the echo pin and wait for it to get HIGH.
Once it got HIGH then we need to count the time for how long it remained HIGH.
On the basis of this time, we are gonna calculate the distance of the object from the ultrasonic sensor.
So, first of all, interface your ultrasonic sensor with arduino as shown in below figure
#define trigPin1 8
#define echoPin1 7
long duration, distance, UltraSensor;
void setup()
{
Serial.begin (9600);
pinMode(trigPin1, OUTPUT);
pinMode(echoPin1, INPUT);
}
void loop() {
SonarSensor(trigPin1, echoPin1);
UltraSensor = distance;
Serial.println(UltraSensor);
}
void SonarSensor(int trigPin,int echoPin)
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
delay(100);
}
Now if you check in the SonarSensor() function, we are generating a pulse of 10 microsecond and sending it to trigPin, which is the trigger pin of our ultrasonic sensor.
After sending this pulse weare using a funcion pulseIn() , its a builtin arduinofunction and is used to check for how long the echoPin remains HIGH.
This value is further saved in the duration value and after that we have divided this duration by 2 because the pulse is first sent and then received so in actual it covers double distance, so we need to divide it by 2 in order to get distance between object and the sensor.
Furthermore, it is again divided by 29.1, which is basically the speed of ultrasonic sound and finally we saved it in a variable named distance which is now in centimeters.
After uploading the sketch in Arduino, you need to open the Serial Terminal and you will start receving the values of distance.
//Button Press Detection
int buttonPin = 7;
void setup(){
pinMode(buttonPin, INPUT);//this time we will set the pin as INPUT
Serial.begin(9600);//initialize Serial connection
}
void loop(){
if (digitalRead(buttonPin)==HIGH){//if button pressed
Serial.println("pressed");
} else {
Serial.println("unpressed");
}
}