Professional Documents
Culture Documents
Hardware Fellowship
Hardware Fellowship
PRESENTS
HARDWARE
FELLOWSHIP
Arduino
Ultrasound
Sensor
Remote
Bot
DAY 1
Bread Board
LM7805 Voltage Regulator
32 KB flash memory
Arduino Programming
Structure:
• Sketch (Language)
• Syntax -> Termination with semicolon(;)
• Control structure ->if, if else, else, for, while etc.
• Operators -> Arithmetic, Comparison
• Casing -> camel Casing
Note: Analog pins can only used for reading analog values (0 - 1023). For
writing analog values, PWM pin are used (so value ranges from 0 to 255)
Arduino Programming
Code Structure
void setup() {
// one time call/run
//all the pins functions/modes are defined here
void loop() {
//continuous run until power off or reset
//codes that should be run continuously are written
.here
}
Arduino Programming
void loop() {
// put your main code here, to run repeatedly:
int a = digitalRead(6);
Serial.println(a);
digitalWrite(5,HIGH);
}
Arduino Programming
Led Blink
//blink led
void setup() {
// put your setup code here, to run once:
pinMode(7,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(7,HIGH);
delay(100);
digitalWrite(7,LOW);
delay(100);
}
Arduino Programming
Millis Function
• Inbuilt function
• Count from 0 t0 49.7 days
void loop() {
// put your main code here, to run repeatedly:
unsigned long current = millis();
if((current - previous) == 500)
{
toggle = !toggle;
digitalWrite(10,toggle);
previous = current;
Serial.println(toggle);
}
}
Sensors
Sensors
1. LDR sensor
2. IR sensor
3. PIR sensor
4. Ultrasonic sensor
5. Condenser mic
LDR sensor
An LDR is a component that
has a (variable) resistance
that changes with the light
intensity that falls upon it.
This allows them to be used in
light sensing circuit.
void loop() {
// put your main code here, to run repeatedly:
int var = analogRead(A0);
Serial.println(var);
if(var > 800){
digitalWrite(13,HIGH);
}
else
{
digitalWrite(13,LOW);
}
}
IR sensor
A passive infrared sensor is an
electronic sensor that measures
infrared light radiating from
objects in its field of view.
}
Ultrasonic sensor
An ultrasonic sensor is an electronic device that
measures the distance of a target object by
emitting ultrasonic sound waves, and converts the
reflected sound into an electrical signal.
components:
the transmitter - which emits the ultrasonic sound
void loop() {
// put your main code here, to run repeatedly:
int data = analogRead(A1);
Serial.println(data);
if(data > 70){
tog = !tog;
digitalWrite(13,tog);
delay(50);
}
}