-
Notifications
You must be signed in to change notification settings - Fork 0
/
OBD for an automobile
79 lines (69 loc) · 1.55 KB
/
OBD for an automobile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//Project on creation of OBD design
//Serial Monitor for the output
//Serial Monitor is on the right topmost corner
#define ECHOPIN 3 //input
#define TRIGPIN 2 //output
float duration;
float duration1;
int distance;
int distance1;
void setup() {
Serial.begin(9600);
pinMode(11,INPUT);
pinMode(10,OUTPUT);
pinMode(13,OUTPUT);
pinMode(11,INPUT);
pinMode(10,OUTPUT);
pinMode(13,OUTPUT);
}
void loop() {
digitalWrite(10,LOW);
delayMicroseconds(2);
digitalWrite(10,HIGH);
delayMicroseconds(10);
digitalWrite(10,LOW);
float duration = pulseIn(11,HIGH);
distance= duration*0.034/2;
Serial.println("\n Brakepads : ");
Serial.print(distance);
Serial.println("mm");
if(distance>12)
{
digitalWrite(13,HIGH);
delay(200);
Serial.println(" \n Thickness of Brakepads is more than the limit");
Serial.println("\n Time to change it");
}
else if(distance>=5){
Serial.println("normal, brakepads are ok");
digitalWrite(13,LOW);
delay(200);
}
else if(distance<5)
{Serial.println("They are torn");
digitalWrite(13,HIGH);
delay(200);
}
digitalWrite(10,LOW);
delayMicroseconds(2);
digitalWrite(10,HIGH);
delayMicroseconds(10);
digitalWrite(10,LOW);
float duration1 = pulseIn(11,HIGH);
distance1= duration1*0.034/2;
Serial.println("\n Engine Coolant Level : ");
Serial.print(distance);
Serial.println("cm");
if(distance>8)
{
digitalWrite(13,HIGH);
delay(200);
Serial.println(" \n coolant is very low as per the limit");
Serial.println("\n time to change it");
}
else if(distance>=5){
Serial.println("normal, coolant level is ok");
digitalWrite(13,LOW);
delay(200);
}
}