Professional Documents
Culture Documents
What’s an Arduino?
Arduino is essentially a tiny computer that can connect to electrical circuits. The Arduino Uno is
powered by an ATmega328P chip, it is the biggest chip on the board as you can see on the picture above.
That’s where you store your programs.
The top row of the Arduino has 14 digital pins, labelled 0-13. These pins can act as either inputs
or outputs. You can connect them to your Circuits to turn them on or off. You can also read buttons – see
if a button is either pressed or not.
On the bottom left row, you can see the power pins. The Arduino has 3.3V or 5V supply. This is
really useful since most components require 3.3V or 5V. You will also find some pins labelled "GND" on
What is a actuator?
In the strict meaning, actuator is a device that converts energy in movement. It could be a valve or a motor.
But I prefer not to be so strict, I consider an actuator anything that can convert electric energy in an output,
for example a display, a led, a loudspeaker.
Arduino can do analog and digital inputs, and only digital outputs. The sensors themselves usually are
analog, but most of times they have a small circuit that translates values into digital format. In some cases
you’ll find both connectors on the same device. So, analog pins on Arduino are always input. Digital pins
can be input or output, your code will decide.
Libraries
In programming, library is a piece of code that someone else previously wrote that can help to use. Most
of, if not all, the peripherals that can be attached to an Arduino have a library. The library controls the
hardware, hiding complexity behind some simple routines that someone else wrote and we can use.
The sensor has only four pins: VCC (Power), Trig (Trigger), Echo (Receive),
and GND (Ground).
If your servo has White - Red - Black wires, then connect it as follows
If your servo has Orange - Red - Brown wires, then connect it as follows
Conclusion :-
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Design Experiments:-
1. Temperature Alarm
2. Push Button and Traffic Lights
long duration;
int distanceft, distanceInch;
#include <Servo.h>
Servo myservo;
int pos = 0;
void setup() {
myservo.attach(10);
Serial.begin(9600);
lcd.begin(16,2);
// Initializes the interface to the LCD screen, and specifies the dimensions (width and
height) of the display
pinMode(trigPin, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A0, OUTPUT);
pinMode(13, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
digitalWrite(A0, HIGH);
digitalWrite(A3, LOW);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distanceft= duration*(0.0133/2)/12;
distanceInch = duration*0.0133/2;
lcd.setCursor(0,0);
// Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("Dist: "); // Prints string "Distance" on the LCD
lcd.print(distanceft); // Prints the distance value from the sensor
lcd.print(" ft");
delay(50);
lcd.setCursor(0,1);
lcd.print("Dist: ");
lcd.print(distanceInch);
Serial.println(distanceInch);
}
else {
// turn LED off:
digitalWrite(13, LOW);
myservo.write(0);
}
}
************************************************************************************