Translate

Cara Memprogram Arduino - TUTORIAL UPLOAD VERIFY IMPORT LIBRARY SOFTWARE ARDUINO IDE

Cara Memprogram Arduino - TUTORIAL UPLOAD VERIFY IMPORT LIBRARY SOFTWARE ARDUINO IDE


            Pada kesempatan kali ini saya akan menjelaskan mengenai basic tutorial dalam memprogram board arduino, jadi akan dicontohkan mengenai bagaimana cara setting awal sebelum memprogram arduino dan juga cara upload yang benar menggunakan software Arduino IDE. Software Arduino IDE yang digunakan kali ini yaitu versi 1.0.5. disini juga dicontohkan mengenai bagaimana cara meletakkan library atau import library. untuk lebih jelasnya berikut penjelasan lengkapnya.




a. Setting Awal Arduino (Pilih Board dan Port)




b. Untuk Menguji Board Arduino Pilih File -> Example -> Basics -> Blink




c. Sehingga seperti berikut, untuk awalan pilih verify lalu upload




d. Untuk import libarary yaitu ekstrak file.rar lalu taruh di Document/Arduino/Libraries/

 




e. VIDEO TUTORIALNYA








ARDUINO ALAT MONITOR JARAK DAN KECEPATAN MULTIPLE SENSOR HB100 DAN HC-SRF04 VIA BLUETOOTH INTERFACE HANDPHONE ANDROID

ARDUINO ALAT MONITOR JARAK DAN KECEPATAN MULTIPLE SENSOR HB100 DAN HC-SRF04 via BLUETOOTH INTERFACE HANDPHONE ANDROID


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk memantau kecepatan dan jarak menggunakan sensor HB100 dan HC-SRF04. alat ini menggunakan interface handphone android. jadi ada dua data yang dikirimkan dari arduino ke handphone android via bluetooth. untuk lebih jelasnya berikut adalah komponen dan programnya. 




a. Arduino Uno




b. Sensor Kecepatan HB100




c. Sensor Jarak HC-SRF04




d. Modul Bluetooth HC-05






e. Program Arduino IDE

 // Frequency input pin: 8 for ARDUINO UNO. Connect the IF pin from the preamp
 // Frequency input pin: 49 for ARDUINO MEGA. Connect the IF pin from the preamp

#include <FreqMeasure.h>
#define trigPin 2
#define echoPin 3

long duration, distance;
int buzzer = 11;
float frequency;
int freq;

void setup() {
  Serial.begin(9600);
  FreqMeasure.begin();
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buzzer, OUTPUT);
  digitalWrite(buzzer, LOW);
}

double sum=0;
int count=0;

void loop() {
  if (FreqMeasure.available()) {
    // average 30 readings together
    sum = sum + FreqMeasure.read();
    count = count + 1;
    if (count > 30) {
       frequency = FreqMeasure.countToFrequency(sum / count);
      float spd = frequency / 19.49; //conversion from frequency to kilometers per hour
      //to improve speed, we update only the bottom row of the LCD
//      Serial.print("F= ");
//      Serial.print(frequency);
//      Serial.print("Hz ");
//      Serial.print("SPD= ");
//      Serial.print(spd);
//      Serial.println("km/h");
 
  freq = frequency;
 
  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;

  Serial.print("Hasil|");
  Serial.print(frequency);
  Serial.print("|");
  Serial.println(distance);
 
  sum = 0;
  count = 0;

    }
  }
 
 
  if((freq <= 5) && (distance <= 10))
  {
  digitalWrite(buzzer, HIGH);
  }
 
  else if((freq > 10)&&(freq < 20) && (distance > 10) && (distance < 20))
  {
  digitalWrite(buzzer, HIGH);
  delay(200);
  digitalWrite(buzzer, LOW);
  delay(200);
  }
 
  else if((freq >= 20) && (distance >= 20))
  {
  digitalWrite(buzzer, LOW);
  }
 
  else
 
  {
  digitalWrite(buzzer, LOW);
  }
 
 delay(300);
}





f. Program Android









g. VIDEO HASILNYA










Membuat Power Supply / Adaptor Sendiri 12v / -12v / 5v / -5v dan GND

Membuat Power Supply / Adaptor Sendiri 12v / -12v / 5v / -5v dan GND


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat power supply atau adaptor yang bisa digunakan untuk power microcontroller atau arduino, adaptor ini juga bisa berfungsi untuk menjalankan alat selain microcontroller yang penting tegangan dan arusnya tidak melebihi batas saja. untuk lebih jelasnya berikut adalah skemanya.



a. SKEMATIK 




b. SKEMA PCB BOARD






c. DAFTAR KOMPONEN

- Dioda 1N4004
- Trafo 2A CT
- Heat sink
- Capasitor Polar 2200uF/50v
- Capasitor Polar 220uF/35v
- Capasitor Polar 100uF/50v
- Capasitor Polar 10uF/50v
- Capasitor Ceramics non Polar 100nF
- Capasitor Milar 100nF / 50v
- IC 7805 dan 7905
- IC 7812 dan 7912
- Resistor 330 ohm / 0.25 watt
- Led 3mm merah
- Pin Screw / T-Block 2 Pin 
- Transistor 2N3055 dan 2N2955
- Kabel Secukupnya





d. VIDEO HASILNYA








Alat Deteksi Gas Alkohol Menggunakan microcontroller ATMega32 BASCOM AVR

Alat Deteksi Gas Alkohol Menggunakan Microcontroller ATMega32 BASCOM AVR


        Pada kesempatan berbahagia kali ini saya akan menjelaskan mengenai bagaimana cara membuat alat yang berfungsi untuk mendeteksi kadar gas alkohol dengan satuan PPM. alat ini menggunakan sensor TGS2620 dan indikator berupa led dan buzzer. interface yang digunakan adalah LCD 16x2. untuk lebih jelasnya berikut adalah komponen dan programnya. 




a. Minimum System ATMega32




b. LCD 16x2




c. Sensor Gas TGS2620






d. Program Bascom AVR 

'tutorial kalibrasi cek link ini
'http://kursuselektronikaku.blogspot.com/2014/09/membuat-detektor-gas-lpg-liquified.html

$regfile = "m32def.dat"
$crystal = 11059200
$baud = 9600

Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2

Cursor Off Noblink
Cls

Config Adc = Single , Prescaler = Auto , Reference = Avcc

Dim Dataadc As Word
 Dim Gas_ref As Word
Dim Gas As Single
Dim Lpg As String * 5
Dim Vol As String * 5
Dim Tegangan As Single
Dim Teganganx As Single
Dim A As Single
Dim Vo As Single
Dim X As Single
Dim Y As Single
Dim Rs As Single
Dim D As Single
Dim E As Single
Dim Ppm As Single
Dim Ro As Single

Ddrd.7 = 1
Ddrd.4 = 1

Portd.7 = 0
Portd.4 = 0

Ddrb.0 = 1
Ddrb.1 = 1

Start Adc

Do

Gas_ref = Getadc(0)                                         'Nilai tegangan ADC dr out sensor
Gas = Gas_ref
Ro = 633750                                                 'kadar Rs dalam udara bersih (ADC minimal)

Teganganx = Gas_ref / 1023
Tegangan = Teganganx * 5.15                                 'untuk Nilai Menampilkan Tegangan

X = 5.15 - Tegangan
Y = X / Tegangan
Rs = Y * 10000                                              'untuk menemukan nilai Rs

D = Rs / Ro
E = 325.0 / D                                               'dari grafik excel ditemukan 325.0x^-1.54
Ppm = E ^ 0.649                                             '1/1.54
Vol = Fusing(tegangan , "#.##")

Locate 1 , 1
Lcd "Vol= " ; Vol ; "       "
Locate 2 , 1
Lcd "PPM= " ; Fusing(ppm , "#.##") ; "       "

If Ppm > 50 Then
Portb.0 = 0
Portb.1 = 1

'buzzer
Portd.7 = 1
Portd.4 = 0

End If

If Ppm < 50 Then
Portb.0 = 1
Portb.1 = 0

'buzzer
Portd.7 = 0
Portd.4 = 0

End If


Waitms 200
Loop






e. VIDEO HASILNYA









ARDUINO SOIL MOISTURE MONITOR KELEMBABAN TANAH

ARDUINO SOIL MOISTURE MONITOR KELEMBABAN TANAH


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk memonitor kelembaban tanah, alat ini menggunakan arduino dan sensor soil moisture, kemudian interface menggunakan lcd 16x2. untuk lebih jelasnya berikut adalah komponen dan programnya



a. Arduino Uno





b. Sensor Soil Moisture




c. LCD 16x2 + I2C






d. Program Arduino IDE

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

int dryValue = 1023;
int wetValue = 0;
int friendlyDryValue = 100;
int friendlyWetValue = 0;
float nddi;
int rawValue;
float mapping;

void setup()
{
lcd.begin();
lcd.clear();
lcd.noCursor();
lcd.backlight();
}

void loop()
{
 
 rawValue = analogRead(A0);          
 //mapping = map(rawValue, dryValue, wetValue, friendlyDryValue, friendlyWetValue);
 //nddi = mapping /100;

  nddi = map(rawValue, dryValue, wetValue, friendlyDryValue, friendlyWetValue);

  lcd.setCursor(0, 0);
  lcd.print("S= ");
  lcd.print(nddi);
  lcd.print("       ");
 
 
/* 
  if( nddi <= -0.05 ){
  lcd.setCursor(0, 1);
  lcd.print("AIR            ");
  }
 
  if(( nddi > -0.05 )&&(nddi <= 0.01 )){
  lcd.setCursor(0, 1);
  lcd.print("NORMAL         ");
  }
 
  if(( nddi > 0.01 )&&(nddi <= 0.15 )){
  lcd.setCursor(0, 1);
  lcd.print("KERING RINGAN   ");
  }
 
  if(( nddi > 0.15 )&&(nddi <= 0.25 )){
  lcd.setCursor(0, 1);
  lcd.print("KERING SEDANG   ");
  }
 
  if(( nddi > 0.25 )&&(nddi <= 1.00 )){
  lcd.setCursor(0, 1);
  lcd.print("KERING BERAT   ");
  }
 
  if( nddi > 1.00 ){
  lcd.setCursor(0, 1);
  lcd.print("KERING SEKALI   ");
  }
*/

 delay(200);
}





e. VIDEO HASILNYA









ARDUINO DETEKSI RGB WARNA MENGGUNAKAN SENSOR TCS3200

ARDUINO DETEKSI RGB WARNA MENGGUNAKAN SENSOR TCS3200


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk mendeteksi RGB warna sehingga akan tampak di LCD 16x2. alat ini cuma menampilkan nilai RGB saja. untuk lebih jelasnya berikut adalah komponen dan programnya.




a. Arduino Uno




b. Sensor Warna TCS3200




c. LCD 16x2 + I2C






d. Program Arduino IDE

#include <Wire.h>  // i2C Conection Library
#include <LiquidCrystal_I2C.h>  //i2C LCD Library

//LiquidCrystal_I2C lcd(0x27, 16, 2);
LiquidCrystal_I2C lcd(0x3F, 16, 2);

#define S0 2
#define S1 3
#define S2 4
#define S3 5
#define sensorOut 6

int frequencyr = 0;
int frequencyg = 0;
int frequencyb = 0;
int jumlah;


void setup() {

  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
  pinMode(sensorOut, INPUT);

  // Setting frequency-scaling to 20%
  digitalWrite(S0,HIGH);
  digitalWrite(S1,LOW);

  Serial.begin(9600);
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
}


void loop() {
  lcd.setCursor(0, 0);
  lcd.print("R  G  B ");
 
  lcd.setCursor(0, 1);
  // Setting red filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,LOW);
  // Reading the output frequency
  frequencyr = pulseIn(sensorOut, LOW);
  // Printing the value on the serial monitor
  lcd.print(frequencyr);//printing RED color frequency
  lcd.print(" ");
  delay(100);
  // Setting Green filtered photodiodes to be read
  digitalWrite(S2,HIGH);
  digitalWrite(S3,HIGH);
  // Reading the output frequency
  frequencyg = pulseIn(sensorOut, LOW);
  // Printing the value on the serial monitor
  lcd.print(frequencyg);//printing RED color frequency
  lcd.print(" ");
  delay(100);
  // Setting Blue filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,HIGH);
  // Reading the output frequency
  frequencyb = pulseIn(sensorOut, LOW);
  // Printing the value on the serial monitor
  lcd.print(frequencyb);//printing RED color frequency
  lcd.println("        ");
  delay(100);


}




e. VIDEO HASILNYA








ARDUINO ETHERNET WEBSERVER TCP-IP MODULE ENC28J60 MONITORING ADC DAN KENDALI LED VIA BROWSER

ARDUINO ETHERNET WEBSERVER TCP-IP MODULE ENC28J60 MONITORING ADC DAN KENDALI LED VIA BROWSER


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang bisa memonitoring ADC dan kendali LED dengan menggunakan browser via kabel LAN / modul tcp-ip ENC28J60. alat ini menggunakan arduino mega dan komunikasi dari arduino ke modul ENC28j60 menggunakan SPI (MOSI MISO SCK). untuk lebih jelasnya berikut adalah program dan daftar komponennya.




a. Arduino Mega




b. Modul ENC28J60






c. Program Arduino IDE

#include <SPI.h>
#include <UIPEthernet.h>

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,99);

EthernetServer server(80);

String readString;

void setup() {

  pinMode(13, OUTPUT);
  Serial.begin(9600);

   while (!Serial) {
  }

  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  int sumbux = analogRead(0);
  int sumbuy = analogRead(1);
  int sumbuz = analogRead(2);

  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
     if (readString.length() < 100) {

          //store characters to string
          readString += c;
          //Serial.print(c);
        }
        if (c == '\n' && currentLineIsBlank) {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");
          client.println("Refresh: 1");
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          client.println(" ");
          client.println("<title> Monitor Kemiringan </title> ");    
          client.println("<body bgcolor = #000000>");    
          client.println("<center>");
            client.println("<font color = yellow><center><h1>MONITOR KEMIRINGAN DATARAN<br>BY YANUAR MUKHAMMAD</h1></center><br></font>");
            client.println("<font color = #FFFFFF>");
            client.println("<h2>");
            client.println("Sumbu X = ");
            client.print(sumbux);
            client.println("<br />");
            client.println("Sumbu Y = ");
            client.print(sumbuy);
            client.println("<br />");
            client.println("Sumbu Z = ");
            client.print(sumbuz);
            client.println("</h2>");     
          client.println("</font>");
           client.println("<a href = \"/?lighton\"\"><input type = 'button' value = 'ON' ></a>");
          client.println("<a href = \"/?lightoff\"\"><input type = 'button' value = 'OFF' ></a> ");
          client.println("</center>");
          client.println("</body>");
          client.println("</html>");
           
          break;      
        }   
        if (c == '\n') {
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          currentLineIsBlank = false;
        }
      }
    }
    delay(1);
    client.stop();
    Serial.println("client disonnected");
  }
          if(readString.indexOf("?lighton") >0)
          {

            digitalWrite(13, HIGH);   
          }
          else{
          if(readString.indexOf("?lightoff") >0)
          {

                digitalWrite(13, LOW);
          }
          }
         readString="";



}




d. VIDEO HASILNYA









Arduino Ethernet TCP-IP Modul ENC28J60 Interface VB 6.0

Arduino Ethernet TCP-IP Modul ENC28J60 Interface VB 6.0


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara mengakses modul ethernet ENC28J60 dengan menggunakan arduino mega.  koneksi dari modul ENC28J60 ke arduino menggunakan pin SPI yaitu mosi miso sck vcc gnd. menurut petunjuk vcc pada modul ENC28J60 yaitu 3.3 volt bukan 5v. untuk lebih jelasnya berikut adalah komponen dan programnya.




a. Arduino Mega




b. Modul ENC28J60






c. Program Arduino Tanpa Interface VB 6.0

#include <SPI.h>
#include <UIPEthernet.h>

byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 177);

EthernetServer server(80);

void setup() {
Serial.begin(9600);
while (!Serial) {
;
}

Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}


void loop() {
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
if (c == '\n' && currentLineIsBlank) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println("Refresh: 1");
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");

int dataadc1 = analogRead(A0);
int dataadc2 = analogRead(A1);
int dataadc3 = analogRead(A2);

client.print("ADC1= ");
client.print(dataadc1);
client.println("<br />");

client.print("ADC2= ");
client.print(dataadc2);
client.println("<br />");

client.print("ADC3= ");
client.print(dataadc3);
client.println("<br />");

client.println("</html>");
break;
}
if (c == '\n') {
currentLineIsBlank = true;
} else if (c != '\r') {
currentLineIsBlank = false;
}
}
}
delay(1);
client.stop();
Serial.println("client disconnected");
}
}





d. Program Arduino Kirim ke Interface VB 6.0

#include <SPI.h>
#include <UIPEthernet.h>

byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 177);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);

EthernetServer server(80);

String readString;
char mm;

void setup() {
pinMode(13,OUTPUT);
Serial.begin(9600);
while (!Serial) {
;
}

Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}


void loop() {
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
boolean currentLineIsBlank = true;
while (client.connected()) {


if (client.available()) {
mm = client.read();
char c = client.read();
Serial.write(c);
if (c == '\n' && currentLineIsBlank) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println("Refresh: 1");
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");

int dataadc1 = analogRead(A0);
int dataadc2 = analogRead(A1);
int dataadc3 = analogRead(A2);

client.print("ADC1= ");
client.print(dataadc1);
client.println("<br />");

client.print("ADC2= ");
client.print(dataadc2);
client.println("<br />");

client.print("ADC3= ");
client.print(dataadc3);
client.println("<br />");

client.println("</html>");

server.println(dataadc1);
server.println(dataadc2);
server.println(dataadc3);

break;
}
if (c == '\n') {
currentLineIsBlank = true;
} else if (c != '\r') {
currentLineIsBlank = false;
}
}





}
delay(1);
client.stop();
Serial.println("client disconnected");
}

          if(mm == 'A')
          {
             digitalWrite(13, HIGH); 
          }
       
          if(mm == 'B')
          {
             digitalWrite(13, LOW);
          }
      
          if(readString.indexOf("?lightof3") >0)
          {
             digitalWrite(13, HIGH); 
          }
       
          if(readString.indexOf("?lightof4") >0)
          {
             digitalWrite(13, LOW);
          }


}





e. Program Interface VB 6.0



Option Explicit
Dim sHari As String      'Deklarasi variabel global, karena digunakan
Dim aHari                'oleh lebih dari satu prosedur
Dim jam, menit, detik
Dim iClientId As Integer

Private Sub cmd_Connect_Click()

On Error GoTo a

If Winsock.State <> sckClosed Then Winsock.Close
Winsock.RemoteHost = Text_IP
Winsock.RemotePort = Text_PORT
Winsock.Connect

sckAccept.RemoteHost = Text_IP
sckAccept.RemotePort = Text_PORT
sckAccept.Connect

cmd_Connect.Enabled = False
cmd_Disconnect.Enabled = True

Exit Sub
a:
MsgBox "error: " & Err.Description, vbCritical, "Error"

End Sub

Private Sub cmd_Disconnect_Click()
Winsock.Close
sckAccept.Close
MsgBox ("Koneksi dengan Server selesai")
cmd_Connect.Enabled = True
cmd_Disconnect.Enabled = False
End Sub


Private Sub Command_Clear_Click()
Text1.Text = ""
End Sub



Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Command2_Click()
' Get the client id from the Combobox
   
    'iClientId = Split(Text_IP, " ")(1)
   
    ' Send data to client
    Winsock.SendData Text2.Text
   
    ' clear textbox
    'txtSendData.Text = ""
   
End Sub

Private Sub Command3_Click()
' Get the client id from the Combobox
   
    'iClientId = Split(Text_IP, " ")(1)
   
    ' Send data to client
    Winsock.SendData Text3.Text
   
    ' clear textbox
    'txtSendData.Text = ""
   
End Sub

Private Sub Form_Load()
aHari = Array("Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu")
               
Timer1.Enabled = True

cmd_Connect.Enabled = True
cmd_Disconnect.Enabled = False




End Sub


Private Sub Timer1_Timer()
sHari = aHari(Abs(Weekday(Date) - 1))
lblTanggal.Caption = "" & sHari & "," & Format(Date, "dd mmmm yyyy")
LblWaktu.Caption = Format(Time, "hh:mm:ss")


End Sub

Private Sub Winsock_Connect()
MsgBox ("terkoneksi dengan server")
End Sub

Private Sub Winsock_ConnectionRequest(ByVal requestID As Long)
Winsock.Accept requestID
End Sub

Private Sub sckAccept_ConnectionRequest(ByVal requestID As Long)
sckAccept.Accept requestID
End Sub

Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)

Dim buffer As String
Dim temp As String
Dim pisah() As String
Dim i As Integer

Dim data As String
data = ""
Winsock.GetData data, vbString
Text1.Text = Text1.Text & data & vbCr

buffer = data

pisah = Split(buffer, Chr$(13))

On Error Resume Next
If buffer <> " " Then
With Text5
    .SelStart = Len(.Text)
    .SelText = buffer
End With
For i = 0 To 2
    If 0 < 3 Then
        Text6(i).Text = CStr(pisah(i))
        End If
        Next i
    Else
    buffer = " "
    End If

End Sub






f. VIDEO HASILNYA








TUTORIAL MENGAKSES ARDUINO FINGERPRINT

TUTORIAL MENGAKSES ARDUINO FINGERPRINT


       Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara mengakses modul fingerprint dengan menggunakan arduino. jadi alat ini bisa mengidentifikasi jari yang didaftarkan pada sensor fingerprint. alat ini sangat tepat sekali untuk projek smart door lock atau project lainnya yang menggunakan fingerprint sebagai ID aksesnya. untuk lebih jelasnya berikut adalah komponen dan contoh programnya. 




a. Arduino Mega




b. Fingerprint Modul






c. Program Arduino IDE

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>

int getFingerprintIDez();

//arduino mega
// pin #10 is IN from sensor (GREEN wire)
// pin #11 is OUT from arduino  (WHITE wire)
SoftwareSerial mySerial(10, 11);


//arduino uno
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
//SoftwareSerial mySerial(2, 3);

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup() 
{
  pinMode(13,OUTPUT);
  digitalWrite(13,LOW);
 
  Serial.begin(9600);
  Serial.println("fingertest");

  // set the data rate for the sensor serial port
  finger.begin(57600);
 
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1);
  }
  Serial.println("Waiting for valid finger...");
}

void loop()                     // run over and over again
{
  getFingerprintIDez();
  delay(50);            //don't ned to run this at full speed.
}

uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }
 
  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }  
 
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;
 
  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);


  if(finger.fingerID == 0){
  Serial.println("Yanuar");
  digitalWrite(13,HIGH);
  }
 
  if(finger.fingerID == 1){
  Serial.println("JONI");
  digitalWrite(13,HIGH);
  }
 
  if(finger.fingerID == 2){
  Serial.println("STEVAN");
  digitalWrite(13,HIGH);
  }

  return finger.fingerID;
}






 d. VIDEO HASILNYA


 






ARDUINO PARSING DATA UART SERIAL alat Monitor Kelembaban Tanah / Soil Moisture dan Potensio Slider WIRELESS HC-12 INTERFACE DELPHI 7

ARDUINO PARSING DATA UART SERIAL alat Monitor Kelembaban Tanah / Soil Moisture dan Potensio Slider WIRELESS HC-12 INTERFACE DELPHI 7  


            Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berfungsi untuk memonitor tegangan dari potensio slider dan kelembaban tanah / soil moisture dengan menggunakan Arduino. alat ini terdapat bagian master dan bagian slave jadi butuh 2 arduino sebagai master dan slave. komunikasi master - slave menggunakan wireless modul HC-12 dan menggunakan parsing data serial uart untuk memilah dua data yang dikirim oleh master kepada slave. untuk lebih jelasnya berikut adalah komponen dan programnya.




a. Arduino Uno




b. Sensor Kelembaban Tanah / Soil Moisture




c. Potensio Slider




d. Modul Wireless HC-12




e. LCD 20x4 + I2C






f. Program Arduino IDE Master

#include <Wire.h>

int dataadc1;
int dataadc2;
int maxval = 1023;
int minval = 0;
int minvalx = 0;
int maxvalx = 100;
int rawValue;

void setup() {
Serial.begin(9600);
}

void loop() {

  dataadc1 = analogRead(A0);
  dataadc2 = analogRead(A1);

int panjang = map(dataadc2, maxval, minval, minvalx, maxvalx);

//secara wireless
Serial.print("*");
Serial.print(dataadc1);
Serial.print(",");
Serial.print(panjang);
Serial.println("#");
//pakai kabel   
//Serial.print(dataadc1);
//Serial.print("\n");
//Serial.print(panjang);
//Serial.print("\n");

delay(1000);
}




g. Program Arduino IDE Slave

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd1(0x26, 16, 2);
LiquidCrystal_I2C lcd2(0x3D, 16, 2);
LiquidCrystal_I2C lcd3(0x3F, 16, 2);

int value1;
int value2;
int hum = 0;
int miring = 0;
int datain1;
int datain2;

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

void setup(){
dataIn=""; 
lcd1.begin();
lcd1.clear();
lcd1.noCursor();

lcd2.begin();
lcd2.clear();
lcd2.noCursor();

lcd3.begin();
lcd3.clear();
lcd3.noCursor();

Serial.begin(9600);
}

void loop(){

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

if(parsing){
    parsingData();
   
    hum = datain1;
    miring = datain2;
   
    Serial.print(hum),Serial.println ('a');
    Serial.print(miring),Serial.println ('b');
 
  lcd1.setCursor(0,0);
  lcd1.print("Hum: ");
  lcd1.print(hum);
  lcd1.print("     ");

  lcd2.setCursor(0,0);
  lcd2.print("Std: ");
  lcd2.print(miring);
  lcd2.print("     ");

  if((miring >= 99)&&(hum > 476)&&(hum < 1023)){
  lcd3.setCursor(0,0);
  lcd3.print("Kondisi Aman    ");
  }
 
  if((miring >= 96)&&(miring <= 98)&&(hum > 340)&&(hum < 475)){
  lcd3.setCursor(0,0);
  lcd3.print("Kondisi Siaga   ");
  }
 
  if((miring < 96)&&(hum < 339)){
  lcd3.setCursor(0,0);
  lcd3.print("Kondisi Bahaya   ");
  }
     
    parsing=false;
    dataIn="";
  } 


 
 
/* pakai kabel
 while(Serial.available()>0)
 { 
 
  value1 = Serial.parseInt();          
  value2 = Serial.parseInt();

  hum = value1;
  miring = value2;

 if(Serial.read()=='\n')
 {
  Serial.print(hum),Serial.println ('a');
  Serial.print(miring),Serial.println ('b');
 
  lcd1.setCursor(0,0);
  lcd1.print("Hum: ");
  lcd1.print(hum);
  lcd1.print("     ");

  lcd2.setCursor(0,0);
  lcd2.print("Std: ");
  lcd2.print(miring);
  lcd2.print("     ");

  if((miring >= 99)&&(hum > 476)&&(hum < 1023)){
  lcd3.setCursor(0,0);
  lcd3.print("Kondisi Aman    ");
  }
 
  if((miring >= 96)&&(miring <= 98)&&(hum > 340)&&(hum < 475)){
  lcd3.setCursor(0,0);
  lcd3.print("Kondisi Siaga   ");
  }
 
  if((miring < 96)&&(hum < 339)){
  lcd3.setCursor(0,0);
  lcd3.print("Kondisi Bahaya   ");
  }
 
 }

 delay(1000); 

}

*/

}


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();

//kirim data hasil parsing
//Serial.print("data 1 : ");
//Serial.print(datain1);
//Serial.print("\n");
//Serial.print("data 2 : ");
//Serial.print(datain2);
//Serial.print("\n");
//Serial.print("data 3 : ");
//Serial.print(dt[2].toInt());
//Serial.print("\n\n");
}




h. Program Interface Delphi 7



unit TA;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls,strutils, TeeProcs, TeEngine, Chart, CPort, mmsystem,
  Series, Buttons;

type
  TForm1 = class(TForm)
    ComPort1: TComPort;
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Chart1: TChart;
    Shape1: TShape;
    Shape2: TShape;
    GroupBox2: TGroupBox;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Memo1: TMemo;
    Label1: TLabel;
    Label2: TLabel;
    Timer1: TTimer;
    Label7: TLabel;
    Label8: TLabel;
    GroupBox4: TGroupBox;
    Edit3: TEdit;
    Edit4: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    BitBtn1: TBitBtn;
    Series1: TFastLineSeries;
    Series2: TFastLineSeries;
    Timer2: TTimer;
    Label5: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Memo1Change(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
comport1.ShowSetupDialog;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if button2.Caption='Connect' then
   begin
   button2.Caption:='Disconnect';
   comport1.Open;
   timer2.Enabled := True;
   end
else if button2.Caption='Disconnect' then
   begin
   button2.Caption:='Connect';
   comport1.Close;
   timer2.Enabled := False;
   end;

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Edit1.Color:=clwhite;
Edit2.Color:=clwhite;
edit1.text:='';
edit2.text:='';
memo1.Text:='';
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
close;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ThousandSeparator:=',';
DecimalSeparator:='.';
end;

procedure TForm1.Memo1Change(Sender: TObject);
var ruang,kulit:double;
    rin,kin:string;
    jumlahdata:integer;

begin
  shape1.Brush.Color:=clgreen;
  shape2.Brush.Color:=clgreen;
  jumlahdata:=chart1.GetMaxValuesCount;
  form1.Caption:=inttostr(jumlahdata);
  if jumlahdata =10000 then
     begin
     chart1.Series[0].Clear;
     chart1.Series[1].Clear;
     end;

  rin:=memo1.Lines[memo1.Lines.count-2];
  kin:=memo1.Lines[memo1.Lines.count-1];

  if rightstr(rin,1)= 'a' then
     begin
     edit1.Text:=leftstr(rin,length(rin)-1);
     ruang:=strtofloat(edit1.text);
     chart1.Series[0].Add(ruang,'',clred) ;
     shape1.Brush.Color:=clred;
     end;
  if rightstr(kin,1)='b' then
     begin
     edit2.Text:=leftstr(kin,length(kin)-1);
     kulit:=strtofloat(edit2.text);
     chart1.Series[1].Add(kulit,'',clgreen) ;
     shape2.Brush.Color:=clred;
     end;

  if (kulit >= 99) and (ruang > 476) and (ruang < 1023) then
  begin
  Label5.Caption := 'AMAN' ;
  end;

  if (kulit >= 96) and (kulit <= 98) and (ruang > 340) and (ruang < 475) then
  begin
  Label5.Caption := 'SIAGA';
  end;

  if (kulit < 96) and (ruang < 339) then
  begin
  Label5.Caption := 'BAHAYA';
  end;


end;


procedure TForm1.Edit1Change(Sender: TObject);
var ruang:double;
begin
ruang:=strtofloat(edit1.text);
if ruang<30 then
   begin
   edit1.Color:=clblue;
   edit3.text:= 'Lembab';
   end;
if ruang>31 then
   begin
   edit1.Color:=clred;
   edit3.text:= 'Kering';
   end;
if (ruang>=31) and (ruang<=30) then
   begin
   edit1.Color:=clwhite;
   edit3.text:= 'Normal';
   end;
end;


procedure TForm1.Edit2Change(Sender: TObject);
var kulit:double;
begin
kulit:=strtofloat(edit2.text);
if kulit<60 then
   begin
   edit2.Color:=clblue;
   edit4.text:= 'Kering';
   end;
if kulit>61 then
   begin
   edit2.Color:=clred;
   edit4.text:= 'Lembab';
   end;
if (kulit>=61) and (kulit<=60) then
   begin
   edit2.Color:=clwhite;
   edit4.text:= 'Normal';
   end;
end;



procedure TForm1.Timer1Timer(Sender: TObject);
begin
label7.Caption:='Date  '+ FormatdateTime('d/mm/yyyy',Date);
label8.Caption:='Time  '+ FormatDateTime('hh:nn:ss',Time);
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
close;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
var
buff:string;
Count:Integer;
begin
comport1.ReadStr(buff,count);
memo1.Text:=memo1.Text+buff;
end;

end.






i. VIDEO HASILNYA