Nikhil Mudgal
Published © GPL3+

Smart Car

Sensors for a car.

IntermediateShowcase (no instructions)1 hour788
Smart Car

Code

Smart Car

Arduino
#include<Wire.h>
#include<rgb_lcd.h>
int ledPin=8;
int buzzer=2;
float temp;
int b=3975;
float resistance;
int a;
int button=4;
const int colorR=90;
const int colorG=20;
const int colorB=50;
rgb_lcd lcd;
void setup() {
  // put your setup code here, to run once:
pinMode(ledPin,OUTPUT);
pinMode(button,INPUT);
pinMode(3,OUTPUT);
Serial.begin(9600);
lcd.begin(16,2);
lcd.setCursor(0,1);
lcd.setRGB(colorR,colorG,colorB);
}


void loop() {
  // put your main code here, to run repeatedly:

int buttonvalue=digitalRead(button);
if(buttonvalue==1)
{
  lcd.print("Engine started!!!");
  digitalWrite(ledPin,HIGH);
a=analogRead(A0);
resistance=(float)(1023-a)*10000/a;
temp=1/(log(resistance/10000)/b+1/298.15)-273.15;

if(temp>85)
{ 
  digitalWrite(buzzer,HIGH);
digitalWrite(ledPin,LOW);
  digitalWrite(3,HIGH);
  lcd.setCursor(0,1);
lcd.setRGB(100,0,0);
lcd.print("Engine overheating !!!");
lcd.print(temp);
delay(3000);
digitalWrite(3,LOW);
}
}
}

Credits

Nikhil Mudgal

Nikhil Mudgal

5 projects • 0 followers

Comments