Tugas Pendahuluan 1 Modul 2




Percobaan 5 Kondisi 2
Semua Switch pull-down, switch 1 dan 3 motor ke kanan, switch 1 dan 4 panah ke kanan

1. Prosedur
[Kembali]
  • Rangkailah semua komponen 
  • Buat program di aplikasi arduino IDE
  • Setelah selesai, masukkan program ke arduino 
  • Jalankan program pada simulasi dan lakukan sesuai kondisi
2. Hardware dan diagram blok [Kembali]
     a. hardware
  • Sensor Infrared
  • Push Button
  • Ic Max7219
  • Dot Matrix
  • Ic L293D
  • Motor DC
  • Arduino UNO

     b. Digram Blok



3. Rangkaian Simulasi dan Prinsip kerja [Kembali]
  • sebelum bekerja
  • setelah bekerja

Prinsip Kerja :
jadi pada percobaan ini, sensor infrared mirip fungsinya sebagai enable yaitu ketika infrared High akan mengizinkan pembacaan input dari Push Button, jika low tidak mengizinkan pembacaan, 

ketika push button 1 dan 3 ditekan bersamaan maka pin arduino yang terhubung dengan terminal IN1 Ic L293D akan high yang kemudian diteruskan ke out1 dan menghidupkan motor.

ketika button 1 dan 4 ditekan bersamaan akan menampilkan bentuk karakter tanda panah ke kanan pada dot matrix

4. FlowChart [Kembali]
a. Listing Program 
#include <LedControl.h>

// Initialize MAX7219 module
LedControl lc = LedControl(5,6,7,1); // Connect DIN, CLK, LOAD (CS) pins to Arduino
byte patterns[8] = {0, 0, 0, 0, 0, 0, 0, 0}; // LED patterns to display

// Pin configuration for dipswitch and motor
const int in1 = A0;
const int in2 = A1;
const int in3 = A2;
const int in4 = A3;
const int infrared = A4;
const int enable = 4;
const int motor1Pin1 = 2;
const int motor1Pin2 = 3;

void setup() {
  // Set up dot matrix module
  lc.shutdown(0, false); // Enable the module
  lc.setIntensity(0, 8); // Set brightness (0-15)
  lc.clearDisplay(0); // Clear the display
 
  // Set pins as output for the motor
  pinMode(enable, OUTPUT);
  pinMode(in1, INPUT);
  pinMode(in2, INPUT);
  pinMode(in3, INPUT);
  pinMode(in4, INPUT);
  pinMode(infrared, INPUT);
  pinMode(motor1Pin1, OUTPUT);
  pinMode(motor1Pin2, OUTPUT);
 
  Serial.begin(9600);
}

void loop() {
  // Read value from infrared sensor
  int infraredValue = digitalRead(infrared);
 
  // Control motor direction based on dipswitch value
  if (infraredValue == HIGH) {
    digitalWrite(enable, HIGH);
   
    bool switch1 = digitalRead(in1) == HIGH;
    bool switch2 = digitalRead(in2) == HIGH;
    bool switch3 = digitalRead(in3) == HIGH;
    bool switch4 = digitalRead(in4) == HIGH;
   
    if (switch1 && switch3 && !switch2 && !switch4) {
      // Forward
      digitalWrite(motor1Pin1, HIGH);
      digitalWrite(motor1Pin2, LOW);
    }
    else if (switch1 && !switch2 && !switch3 && switch4) {
      // Display right arrow
      displayArrowRight();
    }
    else {
      // Stop
      digitalWrite(motor1Pin1, LOW);
      digitalWrite(motor1Pin2, LOW);
      lc.clearDisplay(0); // Clear the display
    }
  }
  else {
    digitalWrite(enable, LOW);
    lc.clearDisplay(0); // Clear the display
  }
}

// Function to display arrow on dot matrix
void displayArrow(byte pattern) {
  for (int row = 0; row < 8; row++) {
    lc.setRow(0, row, pattern);
  }
  delay(500); // Animation speed
  lc.clearDisplay(0);
  delay(500); // Delay before reading input again
}

// Display right arrow
void displayArrowRight() {
  byte arrowRight[8] = {
    B00011000,
    B00001100,
    B00000110,
    B11111111,
    B11111111,
    B00000110,
    B00001100,
    B00011000
  };
  for (int row = 0; row < 8; row++) {
    lc.setRow(0, row, arrowRight[row]);
  }
}

b. Flowchart


5. Kondisi [Kembali]

Semua Switch pull-down, switch 1 dan 3 motor ke kanan, switch 1 dan 4 panah ke kanan

6. Video Simulasi [Kembali]        




7. Download File [Kembali]
  • HTML
  • Video
  • Rangkaian 
  • Arduino
  • Motor 
  • Infrared
  • Ic Max7219
  • Ic L293D

Tidak ada komentar:

Posting Komentar

 BAHAN PRESENTASI UNTUK MATA KULIAH ELEKTRONIKA 2022 NAMA : AKMAL APRIMANTHA NIM : 2110951046 ELEKTRONIKA B DOSEN PENGAMPU : DARWISON.M.T.  ...