Monday, March 7, 2022

DIGITAL CLOCK USING ARDUINO WEMOS D1 + TM 1637 + RTC DS 1307

 




Arduino program

/***************

 * Digital clock Wemos + TM 1637 + DS 1307 

 * TM1637 dan Arduino Wemos

 * youtube channel : Belajar tehnologi jaman now

Koneksi antar Pin :

Wemos                                TM1637
D5                    ------>          CLK     
D6                    ------>          DIO
VCC/3V3        ------>          VCC
GND                ------>          GND


Wemos                               RTC1307
D1                    ------>           SCL 
D2                    ------>           SDA
VCC/3V3        ------>          VCC
GND                ------>         GND

 ***************/

//Library modul TM1637

#include <TM1637Display.h>

#include <Wire.h>

#include "RTClib.h"


RTC_DS1307 rtc;

//koneksi pin CLK ke pin D5 Arduino

//koneksi pin DIO ke pin D6 Arduino

#define CLK D5

#define DIO D6


TM1637Display display(CLK, DIO);


void setup()

{

  rtc.begin();

  display.clear();

  display.setBrightness(0x05);  

  //setting jam pertama kali

 // rtc.adjust(DateTime(2022, 3, 6, 22, 26, 0));

}


void loop()

{  


  DateTime now = rtc.now();

  int jam=now.hour();

  int menit=now.minute();

  display.showNumberDecEx(menit,0,true,2,2);

  display.showNumberDecEx(jam,0x40,true,2,0);

  delay(500);

  display.showNumberDecEx(jam,0,true,2,0); 

  delay(500);

  

}



* library TM1637 : 

  https://github.com/avishorp/TM1637/


Video Youtube Channel :

https://www.youtube.com/channel/UCy9PYJmJXElN9LaHZw_PuTA











Friday, March 4, 2022

Setup Telegrambot long pooling method using php ( with menu keyboard )

<?php //Put Your telegrambot Toke in here define('TOKEN','5198830189:AAEY2XLkRWgkmmZR_EcRtDidKGQDFGESwetrgd'); //setting menu $line1 = array("MENU1","MENU2","MENU3"); $line2 = array("MENU4","MENU5","MENU6"); $line3 = array("MENU7","MENU8","MENU9"); $replyMarkup = array('keyboard' => array($line1,$line2,$line3),
"resize_keyboard" => true,"one_time_keyboard" => false); $encodedMarkup = json_encode($replyMarkup); //Function for send to api bot function Send2Bot($command){ return 'https://api.telegram.org/bot'.TOKEN.'/'.$command; } function SendData2Bot($command,$data){ $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data), ), ); $context = stream_context_create($options); $result = file_get_contents(Send2Bot($command), false, $context); return $result; } function SendCurl($command,$data){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,Send2Bot($command)); curl_setopt($ch, CURLOPT_POST, count($data)); curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec ($ch); curl_close ($ch); return $result; } /* Function to get update from api bot use for long pooling method */ function GetUpdate($offset) { //send to Bot $url = Send2Bot("getUpdates")."?offset=".$offset; $result_send = file_get_contents($url); //Get result and json decode $result_json = json_decode($result_send, true); if ($result_json["ok"]==1) { return $result_json["result"]; } else { return array(); } } function RunningBot() { global $encodedMarkup; $update_id = 0; //start with offset =0, offset set to file //cek if there any file "belajarbot.last_update_id" if (file_exists("belajarbot.last_update_id")) { //if exist, read offsset $update_id = (int)file_get_contents("belajarbot.last_update_id"); } //get new update from ap bot $updates = GetUpdate($update_id); foreach ($updates as $message) { $receiveOK=false; // var_dump($message); $update_id = $message["update_id"];; $message_data = $message["message"]; //jika terdapat text dari Pengirim if (isset($message_data["text"])) { $receiveOK=true; $chatid = $message_data["chat"]["id"]; $message_id = $message_data["message_id"]; $text = $message_data["text"]; $data = array( 'chat_id' => $chatid, 'text' => 'You write message: ' . $text, 'parse_mode' => 'Markdown', 'reply_to_message_id' => $message_id ); //ada menu $data['reply_markup'] =$encodedMarkup; //send message to api bot using curl SendCurl('sendMessage',$data); } //update offset if ($receiveOK){ file_put_contents("belajarbot.last_update_id", $update_id + 1); } } } //Main Program while(true){ sleep(5); //delay 5 second RunningBot(); }



Pemrograman Running text P10 RGB dengan Arduino Nano

Pemrograman Running text P10 RGB dengan Arduino Nano PIN CONNECTION P10 RGB DENGAN ARDUINO NANO/UNO Source code arduino p10 RGB  #include &q...