Translate

Membuat Alat Pijat Otomatis Berbasis Tensimeter Mpx5050DP Interface Android MIT Inventor via Bluetooth

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



MONITOR PH - TDS - SUHU - JARAK BLYNK ESP8266

MONITOR PH - TDS - SUHU - JARAK BLYNK ESP8266 


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapa memonitor PH, TDS, Suhu, Jarak menggunakan Blynk secara realtime. alat ini menggunakan relay sebagi kedali dari pompanya dan juga menggunakan Nodemcu ESP8266 sebagai microcontrollernya. untuk lebih jelasnya berikut adalah koding dan skemanya.



1. Skema 



2. Program Arduino IDE

 #define BLYNK_TEMPLATE_ID "TMPL6wOC--xxx"
#define BLYNK_TEMPLATE_NAME "monitor ph tds"
#define BLYNK_AUTH_TOKEN "VOK0cWiFN5ycHj3SV_snEDXTfTfeixxx"
#define BLYNK_PRINT Serial  

#define  BLYNK_PRINT Serial  
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_ADS1015.h>

#define trigPin D6
#define echoPin D7

#define ONE_WIRE_BUS 2  
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

LiquidCrystal_I2C lcd(0x27,16,2);

Adafruit_ADS1115 ads1115;

long duration, distance;
float TempC;
float pHValue;
long ntu;
int ntunew;
int adcntu;
int adcPH;
int h;
int rawValue;
int TempCx;
int pHValuex;
int ntux;
float ntufix;
int relay1 = D8;
int relay2 = D5;

BlynkTimer timer;

char ssid[] = "hotspothpku";
char pass[] = "123456789";

void sendSensor()
{
 Blynk.virtualWrite(V0, pHValue);
 Blynk.virtualWrite(V1, ntux);
 Blynk.virtualWrite(V2, distance);
 Blynk.virtualWrite(V3, TempC);
 delay(1000);
}

void setup(){ 
sensors.begin();
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
      
ads1115.begin();
ads1115.setGain(GAIN_ONE); 
    
Wire.begin();  

Serial.begin(9600);
lcd.begin();

Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(1000L, sendSensor);
}

void loop(){

  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(2); // Added this line
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
 
adcPH = ads1115.readADC_SingleEnded(0);
pHValue = (adcPH - 2196.84) / 440.283;

adcntu = ads1115.readADC_SingleEnded(1);                   
ntu = (adcntu - 22000.0) / 1;

sensors.requestTemperatures();
TempC = sensors.getTempCByIndex(0); // Celcius

if(ntu < 0){
 ntu = 0; 
}

ntux = map(adcntu, 3000, 0, 0, 100);

if(ntux < 0){
 ntux = 0; 
}

  lcd.setCursor(0,0);
  lcd.print("Ph: ");
  lcd.print(pHValue);
  lcd.print(" ");
  lcd.print(distance);
  lcd.print("    ");
   
  lcd.setCursor(0,1);
  lcd.print("NTU: ");
  lcd.print(ntux);
  lcd.print(" ");
  lcd.print(TempC);
  lcd.print("   ");
  
if(distance <= 10){
 digitalWrite(relay1, HIGH);
}
if(distance > 10){
 digitalWrite(relay1, LOW);
}

if(ntux <= 10){
 digitalWrite(relay2, HIGH);
}
if(ntux > 10){
 digitalWrite(relay2, LOW);
}

  Blynk.run();
  timer.run();
  delay(200);
}


3. VIDEO HASILNYA



Monitoring PH dan Turbidity via Wireless HC-12 LCD TFT ILI9341 Arduino

Monitoring PH dan Turbidity via Wireless HC-12 LCD TFT ILI9341 Arduino


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang bisa memonitoring ph dan turbidity secara realtime dengan sistem wireless. alat ini menggunakan indikator berupa lampu ac 220 volt yang berwarna. interface yang dipakai juga menggunakan lcd tft ili9341. untuk lebih jelasnya berikut adalah koding dan komponennya.


1. Komponen 




2. Program Transmitter

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <SoftwareSerial.h>

SoftwareSerial mySerial (2, 3);

float pHValue;
int tds;
int adctds;
int adcPH;

void setup() {
 mySerial.begin(9600); 
 Serial.begin(9600); 
 pinMode(2, INPUT);
 pinMode(3, OUTPUT);
}

void loop() {

 adcPH = analogRead(A0); //menggunakan pin A0 untuk membaca output sensor pH
 pHValue = (adcPH - 1093.4) / -30.897;

 adctds = analogRead(A1);             
 tds = map(adctds, 900, 1, 0, 100);

mySerial.print("*");
mySerial.print(pHValue * 100);
mySerial.print(",");
mySerial.print(tds);
mySerial.println("#");

//Serial.print(pHValue);
//Serial.print(" ");
//Serial.println(tds);

delay(100);
}


3. Program Receiver

#include <Arduino.h>
#include <math.h>
#include <Wire.h>
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <SoftwareSerial.h>

#define TFT_CS         10
#define TFT_DC         8
//#define TFT_LED      5v
#define TFT_RST        9
#define TFT_MOSI       11
#define TFT_CLK        13
#define TFT_MISO       12

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

SoftwareSerial mySerial (2, 3);

int value1;
int value2;
float ph = 0;
int tds = 0;
int datain1;
int datain2;

int ssrmerahph = 4;
int ssrhijauph = A1;
int ssrkuningph = A2;
int ssrtdsmerah = 7;
int ssrtdshijau = A0;

String dataIn;
String dt[10];
int i;
boolean parsing=false;

void setup(){

pinMode(ssrmerahph,OUTPUT);
pinMode(ssrhijauph,OUTPUT);
pinMode(ssrkuningph,OUTPUT);
pinMode(ssrtdsmerah,OUTPUT);
pinMode(ssrtdshijau,OUTPUT);

  digitalWrite(ssrmerahph,HIGH);
  digitalWrite(ssrhijauph,HIGH);
  digitalWrite(ssrkuningph,HIGH);
  digitalWrite(ssrtdsmerah,HIGH);
  digitalWrite(ssrtdshijau,HIGH);
  
  tft.begin();
  tft.fillScreen(ILI9341_BLACK);
  tft.setTextSize(5);
  tft.setRotation(3); 
  
 dataIn=""; 
// Serial.begin(9600);
 mySerial.begin(9600); 
 pinMode(2, INPUT);
 pinMode(3, OUTPUT);
}

void loop(){

delay(200);

  tft.setCursor(10, 10);
  tft.setTextColor(ILI9341_YELLOW,ILI9341_BLACK);  
  tft.print("PH: ");  
  tft.print(ph);    
  tft.print("  "); 

  tft.setCursor(10, 70);
  tft.setTextColor(ILI9341_GREEN,ILI9341_BLACK);  
  tft.print("TDS: ");  
  tft.print(tds);  
  tft.print("  "); 

if(ph > 8){
  digitalWrite(ssrmerahph,LOW);
  digitalWrite(ssrhijauph,HIGH);
  digitalWrite(ssrkuningph,HIGH);
}

if(ph < 6){
  digitalWrite(ssrmerahph,HIGH);
  digitalWrite(ssrhijauph,HIGH);
  digitalWrite(ssrkuningph,LOW);
}
  
if((ph >= 6)&&(ph <= 8)){
  digitalWrite(ssrmerahph,HIGH);
  digitalWrite(ssrhijauph,LOW);
  digitalWrite(ssrkuningph,HIGH);
}

if(tds < 5){
  digitalWrite(ssrtdsmerah,HIGH);
  digitalWrite(ssrtdshijau,LOW);
}

if(tds >= 5){
  digitalWrite(ssrtdsmerah,LOW);
  digitalWrite(ssrtdshijau,HIGH);
}


//secara wireless
if(mySerial.available()>0) {
    char inChar = (char)mySerial.read();
    dataIn += inChar;
    if (inChar == '\n') {
    parsing = true;
  }
}

if(parsing){
    parsingData();
   
    ph = datain1/100.0;
    tds = datain2;
     
    parsing=false;
    dataIn="";
  } 

}

void parsingData(){
int j=0;

//kirim data yang telah diterima sebelumnya
//Serial.print("data masuk : ");
//Serial.print(dataIn);
//Serial.print("\n");

//inisialisasi variabel, (reset isi variabel)
dt[j]="";
//proses parsing data
for(i=1;i<dataIn.length();i++){
//pengecekan tiap karakter dengan karakter (#) dan (,)
if ((dataIn[i] == '#') || (dataIn[i] == ','))
{
//increment variabel j, digunakan untuk merubah index array penampung
j++;
dt[j]="";       //inisialisasi variabel array dt[j]
}
else
{
//proses tampung data saat pengecekan karakter selesai.
dt[j] = dt[j] + dataIn[i];
}
}

 datain1 = dt[0].toInt();
 datain2 = dt[1].toInt();

}


4. VIDEO HASILNYA



Monitoring Kecepatan Kendaraan Sensor Piezoelectic via Bluetooth Android MIT Inventor

Monitoring Kecepatan Kendaraan Sensor Piezoelectic via Bluetooth Android MIT Inventor 


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat mengukur kecepatan kendaraan menggunakan piezoelectric yang dipasang pada pembatas jalan. alat ini dimonitoring dengan menggunakan handphone via bluetooth dengan software MIT Inventor. untuk lebih jelasnya berikut adalah koding dan skemanya.


a. Skema




b. Koding Android





c. Program Arduino IDE

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <SoftwareSerial.h>

SoftwareSerial mySerial (2, 3);

float kecepatan; 
float t;
int tanda,counter;

void setup() {
 mySerial.begin(9600); 
 Serial.begin(9600); 
 lcd.begin();
 lcd.clear();
 lcd.noCursor();
 pinMode(2, INPUT);
 pinMode(3, OUTPUT);
}

void loop() {

  int v1 = analogRead(A0);
  int v2 = analogRead(A1);

  lcd.setCursor(0, 0);
  lcd.print("1/2= ");
  lcd.print(v1);
  lcd.print("/");
  lcd.print(v2);
  lcd.print("  ");
     
  lcd.setCursor(0, 1);
  lcd.print("V= ");
  lcd.print(kecepatan);
  lcd.print(" m/s ");

if((v1 > 10)&&(tanda == 0)){
  tanda = 1;
  lcd.setCursor(15, 0);
  lcd.print("c");
  }

if((v2 > 15)&&(tanda == 1)){
  tanda = 0;
  t = counter / 1000.0;
  counter = 0;
  kecepatan = 5.0/t;
  lcd.setCursor(15, 0);
  lcd.print(" ");
  }

if(tanda == 1){
counter++;  

mySerial.print(kecepatan);
delay(100);
}



d. VIDEO HASILNYA



Timer Tamiya 3 Lap dan 3 Jalur / Line + Fitur Lastlap

Timer Tamiya 3 Lap dan 3 Jalur / Line + Fitur Lastlap


          Pada kesempatan kali ini saya akan menjelaska mengenai bagaimana cara membuat sebuah alat timer lomba tamiya untuk 3 jalur / Line, alat ini juga dibekali fitur lastlap jika terjadi mobil tamiya yang keluar jalur maka tombol lastlap diaktifkan. untuk lebih jelasnya berikut adalah koding dan skemanya.

  
1. Skema




2. Program Arduino IDE

#include <Wire.h>
#include <SPI.h>        //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <DMD.h>        //Library DMD yang menyediakan fungsi penampilan teks, gambar dsb
#include <TimerOne.h>   //Library peripheral Timer1 untuk menjalankan prosedur pindai panel DMD
#include <Time.h>     //Library waktu yang menyediakan tipe data, struktur, dan obyek waktu
#include "Arial_black_16.h"
#include "Arial_Black_16_ISO_8859_1.h"
#include "Arial14.h"
#include "DejaVuSans9.h"
#include "Droid_Sans_12.h"
#include "Droid_Sans_16.h"
#include "DejaVuSansItalic9.h"
#include "Mono5x7.h"
#include "SystemFont5x7.h"

#define WAKTU_TAMPIL_JAM      10    //detik
#define WAKTU_TAMPIL_KALENDAR 5     //detik

#define DISPLAY_COLUMN_COUNT  2
#define DISPLAY_ROW_COUNT     1

#define PIXELS_PER_COLUMN  32
#define PIXELS_PER_ROW    16

DMD dmd(DISPLAY_COLUMN_COUNT, DISPLAY_ROW_COUNT);
unsigned char show = 0;

char lineBuff[20];
char lineBuff2[20];

int lineA;
int lineB;
int lineC;
int mulai;
int seconds;
int cs;
long start_time = 0;
int lapa,lapb,lapc;
int btlastlap = 5;
int btlastlapx;
int led1 = A0;
int led2 = A1;
int led3 = A2;

void ScanDMD()
{
  dmd.scanDisplayBySPI();
}

void setup(void)
{
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,INPUT);
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(btlastlap,INPUT_PULLUP);

  dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
  Serial.begin(9600);
   //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
  Timer1.initialize( 1000 );           //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
  Timer1.attachInterrupt( ScanDMD );   //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI() 
  //clear/init the DMD pixels held in RAM
  dmd.clearScreen( true );
}

void loop(void)
{

//============================================
lineA = digitalRead(2);
lineB = digitalRead(3);
lineC = digitalRead(4);
btlastlapx = digitalRead(btlastlap);


if(btlastlapx == 1){
if((lineA == 0)&&(lineB == 1)&&(lineC == 1)&&(mulai == 1)){
lapa++;
delay(100);
}

if((lineA == 1)&&(lineB == 0)&&(lineC == 1)&&(mulai == 1)){
lapb++;
delay(100);
}

if((lineA == 1)&&(lineB == 1)&&(lineC == 0)&&(mulai == 1)){
lapc++;
delay(100);
}

if((lineA == 0)&&(lineB == 0)&&(lineC == 1)&&(mulai == 1)){
lapa++;
lapb++;
delay(100);
}

if((lineA == 0)&&(lineB == 1)&&(lineC == 0)&&(mulai == 1)){
lapa++;
lapc++;
delay(100);
}

if((lineA == 1)&&(lineB == 0)&&(lineC == 0)&&(mulai == 1)){
lapb++;
lapc++;
delay(100);
}

if((lineA == 0)&&(lineB == 0)&&(lineC == 0)&&(mulai == 1)){
lapa++;
lapb++;
lapc++;
delay(100);
}

//=============================================
if(lapa > 2){
dmd.clearScreen( true );   
sprintf(lineBuff2, "WIN", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
delay(2000);
dmd.clearScreen( true );  
hasila();  
}

if(lapb > 2){
dmd.clearScreen( true );   
sprintf(lineBuff2, "WIN", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
delay(2000);
dmd.clearScreen( true );  
hasilb();  
}

if(lapc > 2){
dmd.clearScreen( true );   
sprintf(lineBuff2, "WIN", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
delay(2000);
dmd.clearScreen( true );  
hasilc();  
}
}

//===========================================================
if(btlastlapx == 0){
if((lineA == 0)&&(lineB == 1)&&(lineC == 1)&&(mulai == 1)){
dmd.clearScreen( true );   
sprintf(lineBuff2, "WIN", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
delay(2000);
dmd.clearScreen( true );  
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
hasila();  
delay(100);
}

if((lineA == 1)&&(lineB == 0)&&(lineC == 1)&&(mulai == 1)){
dmd.clearScreen( true );   
sprintf(lineBuff2, "WIN", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
delay(2000);
dmd.clearScreen( true );  
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
hasilb();  
delay(100);
}

if((lineA == 1)&&(lineB == 1)&&(lineC == 0)&&(mulai == 1)){
dmd.clearScreen( true );   
sprintf(lineBuff2, "WIN", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
delay(2000);
dmd.clearScreen( true );  
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
hasilc();  
delay(100);
}
}

//=============================================
lineA = digitalRead(2);
lineB = digitalRead(3);
lineC = digitalRead(4);

if((lineA == 0)&&(mulai == 0)){
  delay(200);
  mulai = 1;
  start_time = millis();  
}  

if((lineB == 0)&&(mulai == 0)){
  delay(200);
  mulai = 1;
  start_time = millis();  

if((lineC == 0)&&(mulai == 0)){
  delay(200);
  mulai = 1;
  start_time = millis();  

if(mulai == 1){
seconds = (millis() - start_time) / 1000;
cs = ((millis() - start_time) / 10) % 100;;
}

//===========================================================================  
sprintf(lineBuff, "%d:%d ", seconds, cs);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 37,  3, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);  

sprintf(lineBuff2, "%d/%d/%d ", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  
//===========================================================================

}

void hasila(){
sprintf(lineBuff, "%d:%d ", seconds, cs);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 35,  3, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);  

sprintf(lineBuff2, " A", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  

hasila();  
}


void hasilb(){
sprintf(lineBuff, "%d:%d ", seconds, cs);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 35,  3, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);  

sprintf(lineBuff2, " B", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  

hasilb();  
}


void hasilc(){
sprintf(lineBuff, "%d:%d ", seconds, cs);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 35,  3, lineBuff, strlen(lineBuff), GRAPHICS_NORMAL);  

sprintf(lineBuff2, " C", lapa, lapb, lapc);
dmd.selectFont(Droid_Sans_12);
dmd.drawString( 3,  3, lineBuff2, strlen(lineBuff2), GRAPHICS_NORMAL);  

hasilc();  
}



3. VIDEO HASILNYA


Cara Upload Program Ke Arduino Wifi an Tutorial Connect ke Blynk 2.0

Cara Upload Program Ke Arduino Wifi an Tutorial Connect ke Blynk 2.0



         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara untuk upload koding ke arduino wifi yang mana pada arduino wifi terdapat 2 device yaitu arduino uno dan esp8266. untuk contoh dipakai project untuk monitoring tekanan udara via Blynk 2.0. untuk lebih jelasnya berikut adalah koding dan skemanya.


1. Skema



2. Program Arduino IDE

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

float pressure_pascal;
float pressure_bar;
int dataadc;
int x;
float v;
float kpa;
float mpa;
int buzzer = 7;

void setup() {
 Serial.begin(9600); 
 lcd.begin();
 lcd.clear();
 lcd.noCursor();
 pinMode(buzzer,OUTPUT);
}

void loop() {
 
  x = analogRead(A0);
  v = x*(5.0/1023.0);
  pressure_pascal = (3.0*(v-0.47))*1000000.0;
  pressure_bar = pressure_pascal/10e5;

  lcd.setCursor(0, 0);
  lcd.print("Bar= ");
  lcd.print(pressure_bar);
  lcd.print("   ");

//high 5bar, low 3 bar
if(pressure_bar >= 5){
  digitalWrite(buzzer,HIGH);
  delay(3000);
}

if((pressure_bar >= 3)&&(pressure_bar < 5)){
  digitalWrite(buzzer,LOW);
}   

if((pressure_bar > 0.2)&&(pressure_bar < 3)){
  digitalWrite(buzzer,HIGH);
}  

Serial.println(pressure_bar * 1000);
 
delay(200);  
}



3. Program ESP8266

#define BLYNK_TEMPLATE_ID "TMPL6wOC--xxx"
#define BLYNK_TEMPLATE_NAME "monitor daya"
#define BLYNK_AUTH_TOKEN "VOK0cWiFN5ycHj3SV_snEDXTfTfeixxx"
#define BLYNK_PRINT Serial    

#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
int temp;
int x = 5;
int y;
int value1;
int value2;
int tekanan = 0;
float fix;
float datain1;
String dataIn;
String dt[10];
int i;
boolean parsing=false;
int pinValue;
int pinValue2;
int pinValue3;
BlynkTimer timer;
char ssid[] = "hotspothpku";
char pass[] = "123456789";

void sendSensor()
{
 Blynk.virtualWrite(V0, fix);
 delay(1000);
}

void setup()
{
  dataIn=""; 
  // Debug console
 Serial.begin(9600);
 Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
 timer.setInterval(1000L, sendSensor);
}

void loop()
{
  tekanan = Serial.parseInt();;
  fix = tekanan / 1000.0;
  
  Blynk.run();
  timer.run();
}



4. VIDEO HASILNYA



Alat Hitung Butiran Input Keypad ARduino Sensor IR Proximity

Alat Hitung Butiran Input Keypad ARduino Sensor IR Proximity


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat menghitung butiran misal butiran obat sehingga tak perlu hitung manual. alat ini dibekaki dengan sensor proximity dan arduino nano dengan input keypad 4x4. untuk lebih jelasnya berikut adalah koding dan skemanya.


1. Skema 



2. Program Arduino IDE

#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

char customKey;
const byte ROWS = 4;
const byte COLS = 4;

char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {2,3,4,5};
byte colPins[COLS] = {6,7,8,9};
long angka;

Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
int in1 = 11;
int in2 = 12;
int counter;
int x;

void setup()
{
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  pinMode(in1,OUTPUT);
  pinMode(in2,OUTPUT);
  pinMode(10,INPUT);
  digitalWrite(in1,LOW);
  digitalWrite(in2,LOW);
}

void loop()
{
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);

lcd.setCursor(0,0);
lcd.print("Input Butiran?");
lcd.setCursor(0,1);
lcd.print("Vol: ");  

  customKey = customKeypad.getKey();
  if(customKey >= '0' && customKey <= '9')
    {
      angka = angka * 10 + (customKey - '0');
      lcd.print(angka);
      lcd.print("  ");
    }

   if(customKey == 'A'){         
      lcd.clear();
      delay(1000);
      counter = 0;
      mulai(); 
    }

   if(customKey == 'C'){         
      lcd.clear();
      delay(1000);
      angka = 0; 
    }  
    
delay(200);    
}

void mulai(){

lcd.setCursor(0,1);
lcd.print("Target: ");
lcd.print(angka);
lcd.print(" butir ");

analogWrite(in1,120);
analogWrite(in2,0);

x = digitalRead(10); 

if(x == 0){
counter++;  
}

if(counter >= angka){
analogWrite(in1,0);
analogWrite(in2,0);
delay(200);  
analogWrite(in1,0);
analogWrite(in2,130);
delay(300);
lcd.clear();
return;  
}

lcd.setCursor(0,0);
lcd.print("Vol: ");
lcd.print(counter);
lcd.print("  ");
    
customKey = customKeypad.getKey();

 if(customKey == 'B'){         
   lcd.clear();
   delay(1000);
   return;
 } 

delay(1);       
mulai();  
}



3. VIDEO HASILNYA