Rental Cycle

It is a rental cycle or a calories burner. we can rent it for particular duration and the amount will be deducted by users digital wallet

IntermediateFull instructions provided24 hours280
Rental Cycle

Things used in this project

Hardware components

MSP-EXP430G2 MSP430 LaunchPad
Texas Instruments MSP-EXP430G2 MSP430 LaunchPad
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×2

Software apps and online services

MIT App Inventor 2
MIT App Inventor 2

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Code

cycle.ino

Arduino
e rental cycle
#include<LiquidCrystal.h>
#include <Servo.h> 
LiquidCrystal lcd(13,12,8,9,10,11);
int m;
float total;
Servo Sg90servo;    // create servo object to control a servo 
int angle = 0;    // variable to store the servo position 
char lock=0;
void setup() 
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  Sg90servo.attach(7);
  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(500); // 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() 
{
  if(Serial.available()>0)
  {

  char lock=Serial.read();
    Serial.print(lock);
  if(lock=='0'){
    
     for(angle = 0; angle<=120; angle++)  // goes from 0 degrees to 180 degrees 
  {                                       // in steps of 1 degree 
    Sg90servo.write(angle);              // tell servo to go to position in variable 'angle 
    delay(20);// waits 20ms for the servo to reach the position 
  
  }Serial.write("done"); 
    
  }
   else if(lock=='1'){
     for(angle = 120;angle>=1; angle--)     // goes from 180 degrees to 0 degrees 
  {                                
    Sg90servo.write(angle);              // tell servo to go to position in variable 'angle' 
    delay(20);     // waits 20ms for the servo to reach the position 
    
  } Serial.write("done");
    
   }
  }
  // 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(500); // 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(500);
//    res_lcd();
////    lcd.print
//    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(500);
//    res_lcd();
  }
  
}

PHP Dashboard

PHP
<?php
	// Create connection
    $conn = new mysqli("localhost","id8883869_root", "admin", "id8883869_cycle" );

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
/*echo "Connected successfully <br>";*/
// $var1 = $_GET['email'];
$email1=$_GET['email1'] ;
$plan = $_GET['plan'];

$query = "SELECT * FROM users WHERE email='$email1';";
$result = mysqli_query($conn, $query)or die("result");
$res_array = mysqli_fetch_assoc($result)or die("res_array");
$bal1 = $res_array['bal'];

$query1 = "UPDATE users SET plan = $plan WHERE email='$email1';";
mysqli_query($conn, $query1)or die("update");
 

	if($plan=="1"){
	   $bal1 =$bal1-60;
	}
	else if($plan=="2"){
	   $bal1 = $bal1-120;
	}
	else if($plan=="3"){
	   $bal1 = $bal1-180;
	}
	else if($plan=="6"){
	   $bal1 = $bal1-360;
	}
	else if($plan=="0"){
	   $bal1 = $bal1;
	}
	
$query2 = "UPDATE users SET bal = $bal1 WHERE email='$email1';";
 mysqli_query($conn, $query2)or die("query2");
$query3 = "SELECT * FROM users WHERE email='$email1';";
$resultf = mysqli_query($conn, $query3)or die("resultf");
$res_arrayf = mysqli_fetch_assoc($resultf)or die("res_arrayf");
 $balf = $res_arrayf['bal'];
	echo  $balf;
?>

PHP log in

PHP
<?php
	// Create connection
    $conn = new mysqli("localhost","id8883869_root", "admin", "id8883869_cycle" );

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
/*echo "Connected successfully <br>";*/
// $email = $_GET['email'];
$pass = $_GET['pass'];
$email1=$_GET['email1'] ;
$query = "SELECT *
FROM users
WHERE email='$email1';
";

$result = mysqli_query($conn, $query);
$res_array = mysqli_fetch_assoc($result);
	$bal1 = $res_array['bal'];
// 	echo "$bal1";
	if($res_array['pass'] == $pass){
	
// 	$bal1 = $res_array['bal'];
	echo "true";
	sleep(10);
	echo  $email1;
	}
	else {
	
	echo "false";
	}


?>

Credits

Ritick sethi

Ritick sethi

9 projects • 5 followers
Dr. Umesh Dutta

Dr. Umesh Dutta

38 projects • 39 followers
Working as Director of Innovation Centre at Manav Rachna, India. I am into development for the last 12 years.
Texas Instruments University Program

Texas Instruments University Program

91 projects • 94 followers
TI helps students discover what's possible to engineer their future. Learn about TI tech for the classroom: www.university.ti.com
ravi prakash

ravi prakash

1 project • 0 followers
Energia

Energia

34 projects • 22 followers
Founder of @energiaproject
chandan taneja

chandan taneja

0 projects • 0 followers

Comments