Translate

Input Score Keypad Interface LED Modul P10

Input Score Keypad Interface LED Modul P10


        Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang bisa digunakan untuk menampilkan nilai atau angka / score ke led modul P10 dengan input keypad matrik 4x4. jadi alat ini untuk memulai menampilkan nilai tekan * pada keypad lalu jika ingin melakukan input nilai baru tekan # untuk clear nilai pada lcd lalu input nilainya. untuk lebih jelasnya berikut adalah koding dan skemanya.



a. Skema





b. 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 "DejaVuSansBold9.h"
#include "DejaVuSansItalic9.h"
#include "Droid_Sans_12.h"
#include "Droid_Sans_16.h"
#include "Mono5x7.h"
#include "SystemFont5x7.h"
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);

#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 lineBuffx[20];

long dataku = 0;

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}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A0,A1,A2,A3}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
 
void ScanDMD()
{
  dmd.scanDisplayBySPI();
}

void setup(void)
{
  dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
  Serial.begin(9600);
  lcd.begin();
  lcd.noCursor();
  lcd.clear();
   //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)
{
customKey = customKeypad.getKey();

if(customKey >= '0' && customKey <= '9')
{
 dataku = dataku * 10 + (customKey - '0');
 lcd.setCursor(0,0);
 lcd.print("MASUKKAN SCORE");
 lcd.setCursor(8,1);
 lcd.print(dataku);
}
    
if(customKey == '*'){
 delay(200);
 tampil(); 
}

if(customKey == '#'){
 delay(200);
 lcd.clear();
 dataku = 0; 
}
      
delay(200);
}

void tampil(){
 sprintf(lineBuffx, "%d ", dataku);
 dmd.selectFont(DejaVuSans9);
 dmd.selectFont(Mono5x7);
 dmd.drawString( 33,  0, lineBuffx, strlen(lineBuffx), GRAPHICS_NORMAL);   
//tampil();  
}




c. VIDEO HASILNYA






Monitor DC Voltage Current (Tegangan dan Arus DC) serta RPM Generator Thingspeak

 Monitor DC Voltage Current (Tegangan dan Arus DC) serta RPM Generator Thingspeak


         Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang menggunakan generator sebagai penghasil tegangan dan alat ini digunakan untuk memonitor tegangan dan arus dc yang dihasilkan oleh generator DC tersebut, untuk lebih jelasnya berikut adalah koding dan daftar komponennya.



a. Arduino Uno




b. Nodemcu ESP8266




c. Sensor Arus ACS712




d. Sensor Tegangan DC




e. Sensor RPM





f. Program Arduino Uno

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
SoftwareSerial RFID(4, 5); // RX and TX
LiquidCrystal_I2C lcd(0x27,16,2);

//id kartu55 = 620099C7D3
//id kartu95 = 040088F9FB

volatile byte half_revolutions;
unsigned int rpm;
unsigned long timeold;

String Teks;
String NoKartu  ;  //No kartu RFID

int adcteg;
float tegangan;
int adcarus;
float v;
float arus;
int relay = 8;
boolean state=false;
char c;

int teganganx;
int arusx;
int rpmx;

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

attachInterrupt(0, rpm_fun, RISING);
half_revolutions = 0;
rpm = 0;
timeold = 0;
 
lcd.begin();  
lcd.clear();
lcd.noCursor();
pinMode(relay,OUTPUT);
digitalWrite(relay,HIGH);

}

void loop() {
lcd.setCursor(0,0);
lcd.print("Dekatkan Kartu");

while(RFID.available()>0){
delay(5);
c=RFID.read();
Teks += c;
}
if(Teks.length()>20){
Cek();

if(Teks == "620099C7D3"){
lcd.clear();
delay(1000);
Teks="";
proses();
}

Teks="";
}

}

void proses(){
     
adcteg = analogRead(A0);
tegangan = adcteg * (5.0 / 1023.0) * 4.8;

adcarus = analogRead(A1);
v = adcarus * (5.0 / 1023.0);
arus = (v - 2.5)/0.1;

detachInterrupt(0);  
rpm = 30*1000/(millis() - timeold)*half_revolutions;
timeold = millis();
half_revolutions = 0;
attachInterrupt(0, rpm_fun, RISING);

lcd.setCursor(0,0);
lcd.print("V=");
lcd.print(tegangan);
lcd.print("  ");
lcd.setCursor(9,0);
lcd.print("R=");
lcd.print(rpm,DEC);
lcd.print("   ");
lcd.setCursor(0,1);
lcd.print("I= ");
lcd.print(arus);
lcd.print("   ");

teganganx = tegangan * 100;
arusx = arus * 100;
rpmx = rpm * 1;

Serial.print("*");
Serial.print(teganganx);
Serial.print(",");
Serial.print(arusx);
Serial.print(",");
Serial.print(rpmx);
Serial.println("#"); 

delay(1000);
proses();
}

void Cek()
{
Teks=Teks.substring(1,11);

lcd.setCursor(0,1);
lcd.print("ID: "+Teks);
delay(3000);
lcd.clear();
}

void rpm_fun()
{
   half_revolutions++;
}
 
 

g. Program Nodemcu ESP8266

#include <ThingSpeak.h>  
#include <SPI.h>
#include <ESP8266WiFi.h>

int temp;
int x = 5;
int y;
int counter;

int value1;
int value2;

float tegangan = 0;
float arus = 0;
float rpm = 0;

float datain1;
float datain2;
float datain3;

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

String apiKey = "HGJHGJHY787BNDFH";     //  Enter your Write API key from ThingSpeak
const char* resource = "/update?api_key=";
const char* server = "api.thingspeak.com";

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

WiFiClient client;

void setup()
{
  WiFi.begin(ssid, pass);
  dataIn="";
  // Debug console
  Serial.begin(9600);
}

void loop()
{

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

if(parsing){
  parsingData();   
}

counter++;

if(counter > 10){
    counter = 0;
    kirimdata();
}

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();
datain3 = dt[2].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(datain3);
Serial.print("\n");

//Serial.print("data 3 : ");
//Serial.print(dt[2].toInt());
//Serial.print("\n\n");

 tegangan = datain1 / 100.0;
 arus = datain2 / 100.0;
 rpm = datain3 / 1;

}

void kirimdata(){
   
if(client.connect(server, 80)){
    String postStr= apiKey;
    postStr += "&field1=";
    postStr += String(tegangan);
    postStr += "\r\n\r\n";

   client.print(String("GET ") + resource + apiKey + "&field1=" + tegangan + "&field2=" + arus + "&field3=" + rpm + " HTTP/1.1\r\n" + "Host: " + server + "\r\n" + "Connection: close\r\n\r\n");
   
    client.print("POST /update HTTP/1.1\n");
    client.print("Host: api.thingspeak.com\n");
    client.print("Connection: close\n");
    client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");
    client.print(postStr.length());
    client.print("\n\n");
    client.print(postStr);
    
    Serial.println("%. Send to Thingspeak.");
    
  }

  client.stop();
  Serial.println("Waiting...");
  delay(15000);
  
}



h. VIDEO HASILNYA