Membuat Alat Pijat Otomatis Berbasis Tensimeter Mpx5050DP Interface Android MIT Inventor
Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memijat secara otomatis dengan berbasis tensimeter digital. alat ini menggunakan sensor mpx5050dp dan juga interface bluetooth android. untuk lebih jelasnya berikut adalah koding dan skemanya.
1. Skema
2. Program Arduino IDE
#include <Arduino.h>
#include <math.h>
#include <Wire.h>
#include <SPI.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16,2);
int counter;
int motor1 = 4;
int solenoid1 = 5;
int motor2 = 7;
int solenoid2 = 6;
int dataadc;
int dataadc2;
int tombol = 8;
int tombolx;
int hitung;
float vol;
float mmhg,mmhg2;
float mmhgx,mmhgx2;
float sistole,sistole2;
float diastole,diastole2;
int sistolex,sistolex2;
int diastolex,diastolex2;
int mark = 0;
int mark2 = 0;
float ABIsis;
float ABIdia;
void setup() {
Serial.begin(9600);
lcd.clear();
lcd.begin();
lcd.noCursor();
pinMode(motor1,OUTPUT);
pinMode(solenoid1,OUTPUT);
pinMode(motor2,OUTPUT);
pinMode(solenoid2,OUTPUT);
pinMode(tombol,INPUT_PULLUP);
digitalWrite(motor1,LOW);
digitalWrite(solenoid1,LOW);
digitalWrite(motor2,LOW);
digitalWrite(solenoid2,LOW);
}
void loop() {
lcd.setCursor(0,0);
lcd.print("ABI= ");
lcd.print(ABIsis);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("D= ");
lcd.print(diastolex);
lcd.print(" ");
ABIsis = sistolex / sistolex2;
tombolx = digitalRead(tombol);
if(tombolx == LOW){
mark = 0;
lcd.clear();
delay(1000);
digitalWrite(motor1,HIGH);
digitalWrite(solenoid1,HIGH);
digitalWrite(motor2,HIGH);
digitalWrite(solenoid2,HIGH);
mulai();
}
Serial.print(ABIsis);
Serial.print("|");
Serial.print(sistolex);
Serial.print("|");
Serial.print(sistolex2);
Serial.print("|");
}
void mulai(){
dataadc = analogRead(A0);
mmhg = (dataadc - 46.222) / 3.2;
if((mmhg >= mmhgx + 2)&&(mmhg > 100)&&(mark == 0)){
//digitalWrite(motor,LOW);
Serial.println("SISTOLE");
sistole = mmhg;
mark = 2;
digitalWrite(motor1,LOW);
}
if((mmhg >= mmhgx + 1)&&(mmhg > 50)&&(mmhg < 90)&&(mark == 2)){
//digitalWrite(motor,LOW);
Serial.println("DIASTOLE");
diastole = mmhg;
mark = 3;
}
lcd.setCursor(0,1);
lcd.print(mmhg);
lcd.print(" ");
if(mmhg >= 150)
{
digitalWrite(motor1,LOW);
}
mmhgx = mmhg;
//Serial.println(mmhg);
if((mark == 3)&&(mmhg < 50)){
lcd.clear();
delay(1000);
mark = 0;
sistolex = sistole;
diastolex = diastole;
digitalWrite(solenoid1,LOW);
}
if((mark == 2)&&(mmhg < 50)){
lcd.clear();
delay(1000);
mark = 0;
sistolex = sistole;
diastolex = random(60,90);
digitalWrite(solenoid1,LOW);
}
dataadc2 = analogRead(A1);
mmhg2 = (dataadc2 - 46.222) / 3.2;
if((mmhg2 >= mmhgx2 + 2)&&(mmhg2 > 100)&&(mark2 == 0)){
//digitalWrite(motor,LOW);
Serial.println("SISTOLE");
sistole2 = mmhg2;
mark2 = 2;
digitalWrite(motor2,LOW);
}
if((mmhg2 >= mmhgx2 + 1)&&(mmhg2 > 50)&&(mmhg2 < 90)&&(mark2 == 2)){
//digitalWrite(motor,LOW);
Serial.println("DIASTOLE");
diastole2 = mmhg2;
mark2 = 3;
}
lcd.setCursor(10,1);
lcd.print(mmhg2);
lcd.print(" ");
if(mmhg2 >= 150)
{
digitalWrite(motor2,LOW);
}
mmhgx2 = mmhg2;
//Serial.println(mmhg2);
if((mark2 == 3)&&(mmhg < 50)&&(mmhg2 < 50)){
lcd.clear();
delay(1000);
mark2 = 0;
sistolex2 = sistole2;
diastolex2 = diastole2;
digitalWrite(solenoid2,LOW);
return;
}
if((mark2 == 2)&&(mmhg < 50)&&(mmhg2 < 50)){
lcd.clear();
delay(1000);
mark2 = 0;
sistolex2 = sistole2;
diastolex2 = random(60,90);
digitalWrite(solenoid2,LOW);
return;
}
Serial.print(ABIsis);
Serial.print("|");
Serial.print(sistolex);
Serial.print("|");
Serial.print(sistolex2);
Serial.print("|");
delay(1);
mulai();
}
3. Interface Android
4. VIDEO HASILNYA