LA P4





1. Prosedur  [Kembali]

  1. Rangkai semua komponen 
  2. Buat program di aplikasi arduino IDE
  3. Setelah selesai masukkan program ke arduino 
  4. Jalankan program pada simulasi dan cobakan dengan modul
  5. Lihat hasil pada motor servo dengan menekan tombol keypad 

2. Hardware dan Diagram Blok [Kembali]

a. Arduino

 


b. Motor Servo



c. Breadbord


 d. Keypad



Diagram blok





3. Rangkaian Simulasi dan Prinsip Kerja  [Kembali]






        Pada eksperimen 4 dengan Kondisi 1, kita diminta untuk menggunakan keypad dengan angka 1 hingga 9 untuk memberikan sinyal PWM dari 0 hingga 180, dengan jarak 20 antara setiap nilai PWM. Input yang digunakan adalah keypad,dan outputnya adalah motor servo. Motor servo bergerak secara presisi sesuai dengan sudutnya berdasarkan sinyal PWM yang diberikan. Tujuannya adalah mengatur sudut motor servo sesuai dengan kondisi yang diberikan menggunakan keypad.

4. Flowchart dan Listing Program [Kembali]

   

  • Flowchart 

  • Listing Program 
#include <Servo.h>
#include <Keypad.h>

Servo servoMotor;
const int servoPin = 11; // PWM pin for servo
const int numRows = 4; // Number of rows in keypad
const int numCols = 3; // Number of columns in keypad
char keys[numRows][numCols] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rowPins[numRows] = {9, 8, 7, 6}; // Rows 0 to 3
byte colPins[numCols] = {5, 4, 3}; // Columns 0 to 2

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, numRows, numCols);
void setup() {
servoMotor.attach(servoPin);
servoMotor.write(90); // Initial position
Serial.begin(9600);
}
void loop() {
char key = keypad.getKey();
if (key != NO_KEY) {
Serial.println(key);
// Perform actions based on the key pressed
switch (key) {
case '1':
// Move servo to position 0 degrees
servoMotor.write(20);
break;
case '2':
// Move servo to position 45 degrees
servoMotor.write(40);
break;
case '3':
// Move servo to position 90 degrees
servoMotor.write(60);
break;
case '4':
// Move servo to position 135 degrees
servoMotor.write(80);
break;
case '5':
// Move servo to position 180 degrees
servoMotor.write(100);
break;
case '6':
// Move servo to position 135 degrees
servoMotor.write(120);
break;
case '7':
// Move servo to position 90 degrees
servoMotor.write(140);
break;
case '8':
// Move servo to position 45 degrees
servoMotor.write(160);
break;
case '9':
// Move servo to position 0 degrees
servoMotor.write(180);
break;
default:
break;
}
}
}

5. Kondisi [Kembali]
Modul 2 Percobaan 4

6. Video Demo [Kembali]







7. Link Download [Kembali]
Download HTML [Klik di sini]
Download video rangkaian [Klik di sini]
Download program Arduino [Klik di sini]
Download datasheet Arduino [Klik di sini]
Download datasheet Motor Servo [Klik di sini]














No comments:

Post a Comment

almajri

  Bahan Presentasi Ini Dibuat Untuk Memenuhi  Tugas Mata Kuliah Sistem Digital Dosen : Darwison, M.T Oleh : ALMAJRI KUSMAIDI 2110952003 Ju...