Professional Documents
Culture Documents
Untitled
Untitled
Untitled
Mini Project by
Maaz Khan
M.Aneeb Khan
M.Muez khan
*/
//#include <SD.h>
//#include <SoftwareSerial.h>
#include <LiquidCrystal.h> // library for LCD
//SoftwareSerial gpsSerial(1, 0); // RX, TX
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // initialize the library with the numbers
of the interface pins
double voltage_AC;
double current_AC;
double power_AC;
void setup()
{
//SD.begin(chipSelect);
//gpsSerial.begin(9600);
Serial.begin(9600);// Represent the baud ratewq
lcd.begin(16, 2); // 16 column and 2 rows of lcd
lcd.print(" Mini Project "); // print statement on display on first column and
first row
lcd.setCursor(0,1);
lcd.print(" with Arduino "); // print statement on display on first column and
second row
delay(1500); // delay of 1.5 sec
lcd.clear(); // This will clear the lcd screen
void loop()
{
/*
////////////////////////////////////////////////////////////////////////////////
////////////////////// GPS_SENSOR /////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
if (gpsSerial.available()) {
char c = gpsSerial.read();
if (c == '$') {
String sentence = gpsSerial.readStringUntil('\n');
if (sentence.startsWith("$GPGGA")) {
String fields[15];
int fieldCount = 0;
int i = 0;
while (sentence.length() > 0) {
int index = sentence.indexOf(',');
if (index == -1) {
fields[fieldCount++] = sentence;
sentence = "";
} else {
fields[fieldCount++] = sentence.substring(0, index);
sentence = sentence.substring(index + 1);
}
}
float latitude = fields[2].toFloat() / 100;
float longitude = fields[4].toFloat() / 100;
float altitude = fields[9].toFloat();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Lat: ");
lcd.print(latitude, 6);
lcd.setCursor(0, 1);
lcd.print("Lon: ");
lcd.print(longitude, 6);
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Alt: ");
lcd.print(altitude);
delay(2000);
}
}
}
*/
////////////////////////////////////////////////////////////////////
/////////// DC_SENSOR /////////////////////
//////////////////////////////////////////////////////////////////
adcValue = analogRead(currentPin); // This is for reading the value from analog
pin A0
adcVoltage = (adcValue / 1024.0) * 5000; // Calculating a voltage in mV
currentValue = ((adcVoltage - offsetVoltage) / sensitivity); // Calculating a
current
Serial.print("Raw Sensor Value = " );// As it's a 10-bit ADC board so it's range
will be from 0-1024
Serial.print(adcValue); // print the adc value on lcd
lcd.clear();
delay(1000);
//lcd.display();
lcd.setCursor(0,0);
lcd.print("ADC Value = ");
lcd.setCursor(12,0);
lcd.print(adcValue);
delay(2000);
lcd.setCursor(0,0);
lcd.print("V in mV = ");
lcd.setCursor(10,0);
lcd.print(adcVoltage,1);
delay(2000);
lcd.setCursor(0,0);
lcd.print("Current = ");
lcd.setCursor(10,0);
lcd.print(currentValue,2);
lcd.setCursor(14,0);
lcd.print("A");
delay(2500); // delay of 2.5sec
lcd.clear();
delay(1000);
lcd.setCursor(0,0);
lcd.print(" Voltage = ");
lcd.setCursor(10,0);
lcd.print(Vo,2); // Display the measure voltage with 2 digits after the decimal
point and mask the remaining
lcd.setCursor(14,0);
lcd.print("V");
delay(2000); // delay of 2 sec
lcd.clear();
delay(1000);
lcd.setCursor(0,0);
lcd.print("Voltage_AC = ");
lcd.setCursor(13, 0); // go to voltage position
lcd.print(voltage_AC); // display voltage
delay(2000); // delay of 2 sec
//Measure Ac Current
lcd.setCursor(0,1);
lcd.print("Curr_AC = ");
lcd.setCursor(10, 1); // go to voltage position
lcd.print(current_AC,2); // display voltage
delay(2000); // delay of 2 sec
lcd.clear();
delay(1000);
power_AC = voltage_AC * current_AC; // calculate power
lcd.setCursor(0, 0); // go to beginning
lcd.print("Power: "); // clear previous power reading
lcd.setCursor(7, 0); // go to power position
lcd.print(power_AC); // display power