#include<LiquidCrystal.h>
LiquidCrystal lcd(13,12,8,9,10,11);
int m;
float total;
void setup()
{
// put your setup code here, to run once:
pinMode(2,OUTPUT); // pin 2 configured as output (red led)
pinMode(6,INPUT); // sensor is conected to pin 6
digitalWrite(6,HIGH);
lcd.begin(16,2); // initialize 16x2 LCD
pinMode(5,INPUT_PULLUP); // button to stop the system
Serial.begin(9600);// initialize serial communication at 9600 bps
// greeting messages
lcd.print("Welcome User");
lcd.setCursor(0,1);
lcd.print("Start Ride...");
delay(1500); // wait for 1.5 sec
}
void res_lcd()
{
lcd.clear(); // clear the lcd display
lcd.setCursor(0,0); // put cursor on top left position
}
void loop()
{
// put your main code here, to run repeatedly:
if(digitalRead(6)==HIGH)
{
digitalWrite(2,LOW); // switch off the red led
}
if(digitalRead(6)==LOW)
{
res_lcd();
digitalWrite(2,HIGH); // switch on the red led for pulse indication
m=m+1; // variable for counting number of pedal revolution
total=0.1*m; // variable for storing calories burned
lcd.print(total); // print the calories burnt on lcd
while(digitalRead(6)==LOW); // stay here till the sensor reads low level signal on pin 6*
delay(100);
}
// routine to stop the system and send the caloried burned online
if(digitalRead(5)==LOW) // execute this routine when push button connected to pin 5 is pressed*
{
Serial.print(total); // send the data of total calories burned to bluetooth
res_lcd();
lcd.print("Calories burned:"); // print message on lcd
lcd.setCursor(0,1); // shift cursor to 2nd line
lcd.print(total); // print the calories burned on lcd
delay(2500); // wait fpr 2.5 sec
res_lcd();
lcd.print("sending data...");
Serial.print("*");
Serial.print(total); // send the data of total calories burned to bluetooth
Serial.print("#");
delay(1500);
res_lcd();
lcd.print("data sent...");
lcd.setCursor(0,1);
lcd.print("Thank you...");
m=0; // rest the pulse count
total=0.0; // reset the variable total
delay(1500);
res_lcd();
}
}
Comments
Please log in or sign up to comment.