Arduino Uno
Step: 1
Interfacing IR sensor module with Arduino
How does IR Sensor module work?
IR Sensor and LED with Arduino Uno – Connection Diagram
const int led=13; const int IR=2; void setup() {
// put your setup code here, to run once: Serial.begin(9600); pinMode(led,OUTPUT); pinMode(IR,INPUT);
} void loop() {
// put your main code here, to run repeatedly:
int read=digitalRead(IR); if(read==1){
Serial.println(“light off”); digitalWrite(led,LOW);
} else{
Serial.println(“light on”); digitalWrite(led,HIGH);
}
int buttonPushCounter = 0; int buttonState = 0; int lastButtonState = 0;
void setup()
{
pinMode(buttonPin, INPUT_PULLUP); pinMode(ledPin, OUTPUT);
Serial.begin(9600);
} void loop()
{ buttonState = digitalRead(buttonPin); if (buttonState != lastButtonState)
{ if (buttonState == HIGH)
{ buttonPushCounter++;
if(buttonPushCounter % 2 == 0)
{
Serial.print(“Count”);
Serial.println(buttonPushCounter/2);}
} delay(10);
}
lastButtonState = buttonState; if (buttonPushCounter % 2 == 0)
{
digitalWrite(ledPin, HIGH);
} else { digitalWrite(ledPin, LOW);
}
}
Step: 2
Interfacing Temperature sensor (LM 35) with Arduino
Temperature Sensor Pinout
How does Temperature Sensor module work?
Temperature Sensor with Arduino Uno – Connection Diagram
//formulas
/*Vout = (reading from ADC) * 0.48828125;//analog voltage to temperature in Celciuse Temperature (°C) = Vout * 100 celsius to faranheat—->(C * 9.0 / 5.0) + 32.0;
*/ int SEN=0; void setup() {
Serial.begin(9600);
}
void loop() {
double read=analogRead(SEN); Serial.println(read);
double tempC=read*0.48828125;//analog voltage to temperature equivalent double tempF=(tempC * 9.0 / 5.0) + 32.0;/*converting cencius into faranhit*/
//print tempC and tempF
Serial.print(“Temperature=”);
Serial.print(tempC);
Serial.print(“\xC2\xB0”); // shows degree symbol
Serial.print(“C | “);
Serial.print(tempF);
Serial.print(“\xC2\xB0”);
Serial.println(“F”);
delay(1000);}
Step: 3
Interfacing Ultrasonic sensor with Arduino
Ultrasonic Sensor Pinout
How does Ultrasonic Sensor module work?
Ultrasonic Sensor with Arduino Uno – Connection Diagram
const int trig=33;
const int echo=32;
long dur;
int dist;
void setup() {
Serial.begin(9600);
pinMode(trig,OUTPUT);
pinMode(echo,INPUT);
}
void loop() {
digitalWrite(trig,LOW); //clear the trigpin
delayMicroseconds(2);
digitalWrite(trig,HIGH); //HIGH for 10 sec
delayMicroseconds(10);
digitalWrite(trig,LOW);
dur=pulseIn(echo,HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds
dist=dur*0.034/2; //The speed of ultrasonic sound in air is
Serial.print(dist);
Serial.println(” centimeter”);
}