Showing posts with label Pemrograman. Show all posts
Showing posts with label Pemrograman. Show all posts

[LENGKAP] Membuat Lampu Lalu Lintas Sederhana Dengan Arduino Uno

12:50 PM Comment
Membuat Lampu Lalu Lintas Sederhana Dengan Arduino Uno

Pada artikel kali ini akan di bahas cara membuat lampu lalu lintas dengan sedrhana menggunakan arduino uno

untuk bahan yang dibutuhkan yaitu :

  • Arduino Uno
  • LED merah, kuning, hijau
  • Resistor (untuk membatasi arus pada LED)
  • Kabel  (untuk menghubungkan komponen)
  • Kabel USB untuk menghubungkan Arduino ke komputer
Rangkaian bisa di lihat dibawah ini 

Membuat Lampu Lalu Lintas Sederhana Dengan Arduino Uno

  1. Hubungkan kaki anoda (kaki yang lebih panjang) LED merah, kuning, hijau ke resistor kemudian dari resistor hubungkan ke pin digital pada Arduino (misalnya pada gambar terletak pada Pin 9,8,7).
  2. Hubungkan kaki katoda (kaki yang lebih pendek) LED ke Pin GND Arduino
  3. Upload program dibawah ini



  void setup() {
  pinMode(9, OUTPUT); // LED Merah
  pinMode(8, OUTPUT); // LED Kuning
  pinMode(7, OUTPUT); // LED Hijau
}

void loop() {
  digitalWrite(9, HIGH); // Nyalakan LED Merah
  delay(10000);            // Tunda selama 10 detik
  digitalWrite(9, LOW);  // Matikan LED merah
  
  digitalWrite(8, HIGH); // Nyalakan LED Kuning
  delay(10000);            // Tunda selama 10 detik
  digitalWrite(8, LOW);  // Matikan LED Kuning

  digitalWrite(7, HIGH); // Nyalakan LED Hijau
  delay(10000);            // Tunda selama 10 detik
  digitalWrite(7, LOW);  // Matikan LED Hijau
}
  
led akan hidup bergantian selama 10 detik tiap led, bisa kalian ubah dengan mengubah delay pada program

menggunakan relay dengan program milis pada arduino

11:20 AM Comment

 pada artikel kali ini akan dibahas bagaimana cara mengggunakan program milis pada relay, sehingga kinerja relay bisa berbarengan dengan lainnya, untuk bahan yang diperlukan yaitu

  • arduino uno
  • modu relay
  • kabel jumper
menggunakan relay dengan program milis pada arduino

keterangan :
  • VCC pada modul relay hubungkan ke 5v pada arduino
  • GND pada modul relay hubungkan ke GND pada arduino
  • IN pada relay hubungkan ke pin 8 arduino
berikut ini programnya


int relay = 8;
void setup() {
pinMode(relay,OUTPUT);
}

void loop() {
 unsigned long waktunew = millis();
  digitalWrite(relay,HIGH);
  waktunew = millis();
  while(1){
    if(millis()-waktunew >10000){
      digitalWrite(relay,LOW);
      break;
    }
  }
  waktunew=millis();
  while(1){
    if(millis()-waktunew >1000){
      digitalWrite(relay,HIGH);
      break;
  }
  }
  }

Cara kerja program diatas yaitu relay akan Mati 10 detik kemudian akan Hidup 1 detik
silahkan exsplore cara kerja relay tersebut sesuai keinginan kalian
terimakasih, semoga artikel kali ini dapat membatu 

Cara menggunakan sensor Suhu DS18B20 waterproof dengan Arduino Uno

1:26 PM Comment

Pertama untuk menggunakan sensor suhu DS18B20 waterproof dengan arduino uno yaitu perlu menyiapkan beberapa komponen berikut ini :
  • arduino uno
  • sensor suhu DS18B20 waterproof
  • resistor 4.7k ohm
  • kabel secukupnya
berikutnya lihat rangkaian pada gambar dibawah ini dan ikuti dengan persis


menggunakan sensor Suhu DS18B20 waterproof dengan Arduino Uno


download library terlebih dahulu pada arduino ide dengan cara masuk ke menu sketch > include library > manage libraries... kemudian cari pada kotak pencarian seperti pada gambar berikut ini
pertama cari dengan nama OneWire kemudian instal, dan berikutnya cari lagi dengan nama DallasTemperature

onewire


DallasTemperature

kemudian copy program dibawah ini dan lihat hasilnya pada serial monitor arduino ide

#include <OneWire.h> 
#include <DallasTemperature.h>

const int oneWireBusPin = 2; 
OneWire oneWire(oneWireBusPin);
DallasTemperature sensors(&oneWire);

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

void loop() {
  sensors.requestTemperatures();  
  float celsius = sensors.getTempCByIndex(0);
  float fahrenheit = sensors.toFahrenheit(celsius);

  Serial.print("Suhu Celsius: ");
  Serial.print(celsius);
  Serial.print("°C | Suhu Fahrenheit: ");
  Serial.print(fahrenheit);
  Serial.println("°F");

  delay(1000); 
}

[Lengkap] kalibrasi sensor turbidity dengan mudah

11:02 AM Comment

 

sensor turbidity dengan mudah


pada artikel kali ini adalah lanjutan dari artikel sebelumnya yaitu cara kalibrasi sensor turbidity atau kekeruhan air

int sensorValues = analogRead(A0);
float voltage = sensorValue * (5.0 / 1024.0);
void setup() {
Serial.begin(9600);
}
void loop() {

Serial.println(sensorValues);
delay(500);
}
Pertama copy program diatas kemudian lihat pada serial monitor pada arduino ide uji coba sensor ke air bersih dan lihat berapa nilai analog sensor yang terbaca pada serial monitor kemudian buat program mapping, pada kali ini nilai analog sensor dibatasi dari 0 - 100 dilihat pada program dibawah ini yang diberi warna merah, untuk 420 merupakan nilai analog paling tinggi saat mendeteksi air bersih, jadi ubah nilai 420 sesuai nilai analog sensor yang terbaca saat dicelupkan ke air bersih, program lengkapnya dapat dilihat dibawah ini :
int sensorValues = analogRead(A0);
float voltage = sensorValue * (5.0 / 1024.0);
int kekeruhan = map (sensorValues, 0 ,420, 0, 100);
void setup() {
Serial.begin(9600);
}
void loop() {
  if(kekeruhan > 90){
    Serial.println("Bersih");
  }
  else if (kekeruhan >50){
    Serial.println("Keruh");
  }
  else{
    Serial.println("Kotor");
  }

Serial.println(voltage);
Serial.println(sensorValues);
Serial.println(kekeruhan);
delay(500);
}

Cara Menggunakan Sensor Turbidity/Kekeruhan Air

1:34 PM Comment

Pada artikel ini akan dijelaskan bagaiaman cara menggunakan sensor turbidity atau sensor kekeruhan air dengan menggunakan arduino uno, langsung saja ikuti langkah berikut ini

  • pertama yang perlu disoapkan yaitu :
  • Sensor Turbidity/ Kekeruhan
  • Arduino Uno
  • Kabel Jumper Secukupnya

berikutnya rangkaian dapat dilihat dibawah ini

Cara Menggunakan Sensor Turbidity/Kekeruhan Air

pada gambar diatas digunakan pin analog untuk membaca data yang diterima oleh sensor

berikut ini programnya :



int sensorValues = analogRead(A0);
float voltage = sensorValue * (5.0 / 1024.0);
int kekeruhan = map (sensorValues, 0 ,420, 0, 100);
void setup() {
Serial.begin(9600);
}
void loop() {
  if(kekeruhan > 90){
    Serial.println("Bersih");
  }
  else if (kekeruhan >50){
    Serial.println("Keruh");
  }
  else{
    Serial.println("Kotor");
  }

Serial.println(voltage);
Serial.println(sensorValues);
Serial.println(kekeruhan);
delay(500);
}

Cara Upload Program Pada ESP32 CAM

8:04 AM Comment

Artikel kali ini membahas mengenai cara upload coding pada ESP32 CAM. Seperti yang sudah disebutkan pada artikel sebelumnya bahwa ESP32-CAM tidak mempunyai port khusus seperti mikrokontroler yang mempunyai port Micro USB untuk upload program, dengan demikian maka diperlukan perangkat tambahan supaya dapat melakukan upload program ke board ESP32-CAM. Perangkat tambahan yang dapat digunakan yaitu FTDI FT232RL. FTDI memiliki fungsi yang sama seperti port untuk disambungkan dengan USB. dibawah ini merupakan gambar rangkaiannya.


Keterangan :

  • ESP32-CAM > FTDI
  • GND dihubungkan ke GND
  • 5V dihubungkan ke VCC (5V)
  • U0R dihubungkan ke TX
  • U0T dihubungkan ke RX
  • GPIO 0 dihubungkan ke GND
Setelah semua terhubung maka sebelum upload program instal terlebih dahulu USB driver dari FTDI
Selanjutnya uji coba program seperti biasanya

HTML and CSS Code Tutorial For Beginners

3:37 PM Comment

 

HTML and CSS Code Tutorial For Beginners

What is CSS ?

CSS stands for Cascading Style Sheet, which is an arrangement of code that we use to set how HTML documents will be displayed. What is meant by setting here is: changing the color, layout, border, shadow, position, background, and so on.

In fact, all web pages in this era almost certainly use CSS.

Inserting CSS in HTML

There are 3 ways to add CSS to HTML:

  • Using inline CSS.
  • Using internal CSS.
  • and Using external CSS.

Using inline CSS

Inline CSS is a CSS code that we embed in any element in the HTML body, directly using the attribute style

Example

<button>Log In</button>

<button>Register</button>

Output:

We can change the style of the two buttons above by adding attributes style

<button style="color: red">Log In</button>

<button style="color: blue; border: 2px solid green">

  Register

</button>

Output:

Well, the method above is called inline CSS, because we directly insert CSS on that line as well.

Using internal CSS

The second way is to use internal CSS. Internal CSS is CSS that is placed on the <head>

Example

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>CSS Internal</title>

</head>

<body>

  <a href="#">Home</a>

  <a href="#">About</a>

</body>

</html>

Output:

CSS Internal Home About

We can add tags <style> in the <head>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>CSS Internal</title>

 

  <style>

    a {

      padding: 8px 16px;

      border-radius: 4px;

      color: white;

      background-color: #8d68e8;

      text-decoration: none;

      font-family: Arial, Helvetica, sans-serif;

    }

  </style>

</head>

<body>

  <a href="#">Home</a>

  <a href="#">About</a>

</body>

</html>

Output:



Using external CSS

What is meant by external is that we create a separate file with the extension .css. Then we link the file into the HTML page using the tag <link>

Example

├── index.html

└── style

    └── app.css

So we have two files

Index.html

Style/app.css

We can add a <link> tag in the <head> section that points to the style/app.css file as follows

While the contents of the style/app.css file are as follows

<html lang="en">

<head>

  <meta charset="UTF-8">

  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>CSS Eksternal</title>

  <link rel="stylesheet" href="./style/app.css">

</head>

<body>

  <a href="#">Home</a>

  <a href="#">About</a>

</body>

</html>

While the contents of the style/app.css file are as follows

a {

  padding: 8px 16px;

  border-radius: 4px;

  color: white;

  text-decoration: none;

  font-family: Arial, Helvetica, sans-serif;

}

a:first-of-type {

  background-color: #1fc296;

}

a:last-of-type {

  background-color: #d45a5a;

}

Note : In the use of external CSS we do not need to use the tag <style>

Output:



When to Use inline, internal and external CSS ?

Ideally in real projects, we should always use external CSS.

Why?

So that the arrangement of files in our project becomes neater. And also: so that we can use the same CSS file for more than one HTML page.

However, there are times when we prefer to use internal or inline CSS. Like for example when we only need a little CSS on an element


Tutorial For Making Form In Html For Beginners

1:27 PM Comment
Tutorial For Making Form In Html For Beginners

Among the important features of HTML are: form tags. That is a tag that we use to collect input from users, this concept is the same as the concept of forms in the real world.

Generally, a website always has a form feature, the most common examples we often encounter are:

login form

sign-up form

comment form on a blog / media

Element <form>

The most important is the tag or element <form>. It is a wrapping tag or container that represents a “form” where one form can have multiple fields.

<form>

...........

</form>

The <form> tag itself does not have any appearance or is invisible to the naked eye, but we still have to define it so that the form we create can work properly.

Elemen <input>

In HTML, there are many types of input models ranging from text, files, checklists, and so on which, God willing, we will discuss in more detail in the next few meetings.

And most of these types of fill models use <input> tags.

Example

<input type="text" name="name" value="joe">

Output :

The input tag has 2 basic attributes, namely:

  • type
  • and names.

The type attribute is used to define the type of the field, while the name attribute is the name of the field.

Several types of input tag input types such as text (default), radio, checkbox, submit, button and so on:

<input type="text">

<!-- choice (a, b, c, d) -->

<input type="radio">

<!-- type ceklis -->

<input type="checkbox">

<!-- button for submit -->

<input type="submit">

<!-- button not for submit -->

<input type="button">

Text Field

The first is a text field, it is an input tag with a type="text" attribute that functions to collect text fields from the user.

Even without writing type="text", the default type of an input is text.

Example

<form>

  <div>

    <label for="first-name">First Name</label> <br>

    <input id="first-name" name="first-name" placeholder="First Name">

  </div>

  <div style="margin-top: 1rem">

    <label for="last-name">Last Name</label> <br>

    <input id="last-name" name="last-name" placeholder="Last Name">

  </div>

</form>

output :



In the code above, we use the <div> element to wrap the <label> and <input> elements. The use of the <div> element here only works so that the label and input are displayed in a new line, so even without using a <div> is fine.

One more thing, because the <label> and <input> elements are inline elements, we must use a "certain way" (such as using the <br> tag) so that the label and input are displayed on a new line.

If you don't use div or br (as in the example below):

<form>

    <label for="first-name">First Name</label>

    <input id="first-name" name="first-name" placeholder="First Name">

    <label for="last-name">Last Name</label>

    <input id="last-name" name="last-name" placeholder="Last Name">

</form>

The output will be inline:

Element <label>

Take a look at the HTML code above: we have two <label> elements.

The <label> element does look like a typical <span> element, but it has a special function: to label an input field.

Because when a screen reader reads the content of an HTML page, then finds an input, it will read the corresponding label.

Another function of the <label> tag is: when we click on a label, the browser will put focus on the field associated with it.

We can associate an <label> and an <input> with the for attribute for the label, and the id attribute on the <input> with the exact same value.

Consider the following example:

<label for="input-name">Name</label>

<br>

<br>

<input id="input-name">

In the code above, the <input> element has an id of name-field, and the label element has a for attribute with the same value, namely name-field.

Output :



Radio Button

Next is the field with the radio type. It is an option type field where we can offer several options to the user. However, only one option can be selected.

Example

<form>

  Gender: <br>

  <div>

    <input id="ml" type="radio" name="gender_">

    <label for="ml">Male</label>

  </div>

  <div>

    <input id="fl" type="radio" name="gender_">

    <label for="fl">female</label>

  </div>

</form>

Output:

Gender:

In the options above, we can only choose one of each.

The thing to note is that the name attribute of each radio button must have the same value in a set of options. In the example above, we have gender_

Check boxes

Next is the checkbox or checklist. The difference with radio, we can choose more than one option in a set of options.

Let's change all type="radio" in the previous code to type="checkbox". 

<form>

  Gender: <br>

  <div>

    <input id="ml" type="checkbox" name="gender_">

    <label for="ml">Male</label>

  </div>

  <div>

    <input id="fl" type=" checkbox " name="gender_">

    <label for="fl">female</label>

  </div>

</form>

Output :

Gender:

In the example above we can select (tick) all the available options.

Element button submit

The next input element that we will discuss in this form introduction is input type submit.

It is an <input> displayed in the form of a button. If this input is clicked, the form will be submitted and the browser will start sending data.

Example :

<form>

  <input type="text" name="name" value="Joe"> <br>

  <input type="submit" value="Submit">

</form>

output :


We can also use element <button>

<form>

  <input type="text" name="name" value="joe"> <br>

  <button>Submit</button>

</form>

Buttons that are in a form will automatically be considered type="submit". If we want to create a plain button that doesn't submit <form>, we can add the attribute type="button"

In the code above, when the "Save" button is clicked, it will not submit the form because it is of type normal button (type="button"), not submit type

How to Process the Form

When a <form> is submitted, using either a <button> element or an <input type="submit">, the browser will send the data to the URL defined in the action attribute in the form tag.

Meanwhile, if the action attribute is not defined, the browser will use the current URL as the destination for sending data.

Example :

<form action="/ process-registration ">

  ...

</form>

In the example above, when the form is submitted, the browser will send the existing data to the URL /process-registration


Program Array Python Basic

6:30 AM Comment

 

Program Array Python Basic

Array merupakan kumpulan dari beberapa variable yang memiliki nama serta tipe data yang sama, atau pengelompokan dengan data atau dama yang sama

Contoh hasil program array

Input : arr [] = {2,3,4}

Output : 9

2 + 3 + 4 = 9

Contoh program array menggunakan python dengan Iterasi melalui array dan menambahkan setiap elemen ke variabel jumlah dan menampilkan hasilnya.

[program 1]

#Program  untuk menemukan jumlah elemen 
#dalam array yang diberikan
def _sum(arr):
    sum = 0
    for i in arr:
        sum = sum + i
    return(sum) 
arr = []
arr = [15, 4, 9, 12]
n = len(arr)
ans = _sum(arr)
print('Sum of the array is ', ans)

output :

hasil jumlah array 40

cara kedua yaitu menggunakan fungsi sum(), sum() merupakan fungsi bawaan yang ada pada python

[program 2]

#Program  untuk menemukan jumlah elemen 
#dalam array yang diberikan
arr = []
arr = [15, 4, 9, 12]
ans = sum(arr)
print('Sum of the array is ', ans)

output :

hasil jumlah array yaitu 40

itulah beberapa contoh metode yang dapat digunakan pada program python basic untuk array, tunggu update artikel tentang belajar python selanjutnya ya, semoga bermanfaat


Contoh Program Python Memilih Nilai Terbesar

11:30 AM Comment

 

Contoh Program Python Memilih Nilai Terbesar

Diberikan dua angka dan tugasnya yaitu memilih angka terbesar dengan menggunakan fungsi maximum

Contoh pertama menggunakan fungsi python if else untuk menemukan hasilnya

[program 1]

# program python untuk menemukan
# nilai maksimum dari dua angka
def maximum(a, b):
    if a >= b:
        return a
    else:
        return b      
a = 3
b = 5
print(maximum(a, b))

output dari program diatas yaitu 5

cara membacanya yaitu jika variabel “a” lebih besar dari variable “b” maka outputnya variabel “a” tetapi jika salah maka outputnya variabel “b”

dan pada program python diatas variabel “a” diberikan nilai 3 dan variabel “b” diberikan nilai 5 maka nilai yang dibaca yaitu variabel “b”

contoh program menggunakan fungsi max untuk menemukan hasilnya

[program 2]

# program python untuk menemukan
# nilai maksimum dari dua angka
a = 3
b = 5
maximum = max(a, b)
print(maximum)

output nya 5

jika menggunakan fungsi max program python akan menjadi lebih sederhana, namun cara kerjanya juga sama dengan program 1 tadi, hanya saja penulisannya lebih simpel karena menggunakan fungsi yang telah disediakan python

contoh ketiga yaitu menggunakan ternary operator

prinsipnya sama seperti program 1 namun pada program 3 ini rumus untuk mencari hasilnya hanya ditulis dalam 1 baris saja didalam () dengan tetap menggunakan fungsi python if

[program 3]

# program python untuk menemukan
# nilai maksimum dari dua angka
a = 3
b = 5
# penggunaan operator ternary
print(a if a >= b else b)

outputnya 5

itulah beberapa contoh program python basic untuk mencari nilai maksimum dari dua angka, mulai dari menggunakan fungsi python if, fungsi max dan menggunakan operator ternary, tunggu update artikel tentang belajar python selanjutnya ya, semoga bermanfaat


Contoh Program Python Penjumlahan

9:19 AM Comment

 

Contoh Program Python Penjumlahan

Penjumlahan dua angka pada python, misalnya diberikan dua angka dan tugasnya yaitu menuliskan program python untuk mencari hasil dari penjumlahan tersebut

Contoh hasil outputnya :

Input: num1 = 3, num2 = 2

Output = 5

Dalam program di bawah ini untuk menambahkan dua angka,  pertama-tama kalian diminta untuk memasukkan dua angka dan input dipindai menggunakan fungsi input() dan disimpan dalam variabel angka1 dan angka2. Kemudian variabel bilangan1 dan bilangan2 dijumlahkan menggunakan operator aritmatika + dan hasilnya disimpan dalam variabel penjumlahan. Di bawah ini adalah program Python untuk menambahkan dua angka:

[program 1]

# Python3 program to add two numbers
num1 = 11
num2 = 10
# Adding two nos
sum = num1 + num2
# printing values
print("Sum of {0} and {1} is {2}" .format(num1, num2, sum))

Output nya yaitu

jumlahnya 11 dan 10 yaitu 21

Contoh penjumlahan bilangan desimal yaitu :

[program 2]

# Python3 program to add two numbers
number1 = input("angka pertama: ")
number2 = input("\nangka kedua: ")
# Adding two numbers
# User might also enter float numbers
sum = float(number1) + float(number2)
# Display the sum
# will print value in float
print("The sum of {0} and {1} is {2}" .format(number1, number2, sum))

angka desimal bisa kalian tambahkan sendiri pada saat program di runing

Output dari contoh program python diatas yaitu :

angka pertama : 10.5 angka kedua : 11.5

jumlah dari 10.5 dan 11.4 yaitu 21.9

itulah contoh program python basic tentang penjumlahan yang cocok untuk kalian yang sedang ingin belajar mendalami python, tunggu update contoh program python menarik selanjutnya ya, semoga bermanfaat


Instal chrome ubuntu

1:44 PM Comment

Google Chrome is one of the most widely used browsers by humans today. However, Google Chrome is not in the official Ubuntu repositories because Google Chrome is not an open source software

Download Google Chrome

There are two ways. The first is downloaded from the official website, and the second is downloaded via the terminal.

To download google chrome from their official site, you can directly visit the following url

https://www.google.com/chrome/browser/desktop/index.html.

Click the download button.

Instal chrome ubuntu

choose the format .deb

Instal chrome ubuntu

Instal chrome ubuntu

Download via terminal

open terminal then move to folder download

cd downloads/

And write the following command to download google chrome.

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

If the download process is complete, check with the ls command. There is now a file with the name google-chrome-stable_current_amd64.deb.

Install Google Chrome

To install it, we just open the terminal.

Move to the directory where our google chrome files are located.

Once we are in the correct location, we can install google chrome with the following command:

sudo dpkg -i google-chrome-stable_current_amd64.deb

Error Install Google Chrome

Google chrome has some dependency requirements. If these requirements have not been installed, then the Google Chrome installation process will experience interference and Google Chrome will not be able to be opened.

The fix is ​​to do the command

sudo apt-get -f install

If the above process has been successful, you can run Google Chrome through the application menu

Instal chrome ubuntu