Percobaan 5 Kondisi 1
1. Prosedur [Kembali]
1. Rangkai rangkaian di proteus sesuai dengan kondisi percobaan.
2. Tulis program untuk arduino di software Arduino IDE.
3. Compile program tadi, lalu upload ke dalam arduino.
4. Setelah program selesai di upload, jalankan simulasi rangkaian pada proteus.
2. Tulis program untuk arduino di software Arduino IDE.
3. Compile program tadi, lalu upload ke dalam arduino.
4. Setelah program selesai di upload, jalankan simulasi rangkaian pada proteus.
2. Hardware dan Diagram Blok [Kembali]
3. Rangkaian Simulasi dan Prinsip Kerja [Kembali]
Pada percobaan 5 digunakan button sebagai input, yang mana disini button pull down, ketika switch ditutup maka arus akan mengalir dari VCC dan memerikan logika high pada pun arduino. kemudian melalui programm arduino akan memproses pin input dan menghasilkan output sesuai dengan kondisi yang diberikan. Ketika switch 1 dan 3 ditekan, maka motor akan bergerak ke kanan, yang mana dari arduino motor terlebih dahulu dihubungkan dengan L293D yang berfungsi sebagai driver atau penggerak dari motor, sedangkan ketika button 2 dan 4 ditekan, maka dot matrix akan menampilkan tanda panah yang mengarah ke kanan dan sebelum dihubungkan ke dot matrix, arduino dihubungkan dengan MAX7219 untuk mengatur atau mengontrol dot matrix.
Flowchart :
Listing Program:
#include <LedControl.h>
// Initialize the MAX7219 moduleLedControl lc = LedControl(5, 6, 7, 1); // Pin DIN, CLK, LOAD (CS) connected to Arduino
const int switch1Pin = A0; // Switch 1 connected to pin A0const int switch2Pin = A1; // Switch 2 connected to pin A1const int switch3Pin = A2; // Switch 3 connected to pin A2const int switch4Pin = A3; // Switch 4 connected to pin A3
const int pin3Output = 4; // Output pin connected to pin 3 (motor control)const int pin4Output = 3; // Output pin connected to pin 4 (motor control)
const int motor1Pin1 = 2;const int motor1Pin2 = 3;
void setup() { // Set up the dot matrix module lc.shutdown(0, false); // Activate the module lc.setIntensity(0, 8); // Set brightness (0-15) lc.clearDisplay(0); // Clear the display
// Set up pins for motor control pinMode(pin3Output, OUTPUT); pinMode(pin4Output, OUTPUT); pinMode(motor1Pin1, OUTPUT); pinMode(motor1Pin2, OUTPUT);
// Set up switch pins pinMode(switch1Pin, INPUT); pinMode(switch2Pin, INPUT); pinMode(switch3Pin, INPUT); pinMode(switch4Pin, INPUT);
Serial.begin(9600);}
void loop() { int switch1State = digitalRead(switch1Pin); int switch2State = digitalRead(switch2Pin); int switch3State = digitalRead(switch3Pin); int switch4State = digitalRead(switch4Pin);
// Check if all switches are active (LOW) if (switch1State == HIGH && switch2State == HIGH && switch3State == HIGH && switch4State == HIGH) { digitalWrite(pin3Output, LOW); digitalWrite(pin4Output, LOW); lc.clearDisplay(0); } else { // Check if switch 1 and 3 are active if (switch1State == HIGH && switch3State == HIGH) { digitalWrite(pin3Output, HIGH); digitalWrite(pin4Output, LOW); lc.clearDisplay(0); } else { digitalWrite(pin3Output, LOW); }
// Check if switch 2 and 4 are active if (switch2State == HIGH && switch4State == HIGH) { digitalWrite(pin3Output, LOW); digitalWrite(pin4Output, LOW); displayArrowRight(); } }}
void displayArrowRight() { byte arrowRight[8] = { B00011000, B00001100, B00000110, B11111111, B00000110, B00001100, B00011000, B00000000 }; for (int row = 0; row < 8; row++) { lc.setRow(0, row, arrowRight[row]); } delay(500); lc.clearDisplay(0); delay(500);}
Flowchart :
Listing Program:
#include <LedControl.h>
// Initialize the MAX7219 module
LedControl lc = LedControl(5, 6, 7, 1); // Pin DIN, CLK, LOAD (CS) connected to Arduino
const int switch1Pin = A0; // Switch 1 connected to pin A0
const int switch2Pin = A1; // Switch 2 connected to pin A1
const int switch3Pin = A2; // Switch 3 connected to pin A2
const int switch4Pin = A3; // Switch 4 connected to pin A3
const int pin3Output = 4; // Output pin connected to pin 3 (motor control)
const int pin4Output = 3; // Output pin connected to pin 4 (motor control)
const int motor1Pin1 = 2;
const int motor1Pin2 = 3;
void setup() {
// Set up the dot matrix module
lc.shutdown(0, false); // Activate the module
lc.setIntensity(0, 8); // Set brightness (0-15)
lc.clearDisplay(0); // Clear the display
// Set up pins for motor control
pinMode(pin3Output, OUTPUT);
pinMode(pin4Output, OUTPUT);
pinMode(motor1Pin1, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
// Set up switch pins
pinMode(switch1Pin, INPUT);
pinMode(switch2Pin, INPUT);
pinMode(switch3Pin, INPUT);
pinMode(switch4Pin, INPUT);
Serial.begin(9600);
}
void loop() {
int switch1State = digitalRead(switch1Pin);
int switch2State = digitalRead(switch2Pin);
int switch3State = digitalRead(switch3Pin);
int switch4State = digitalRead(switch4Pin);
// Check if all switches are active (LOW)
if (switch1State == HIGH && switch2State == HIGH && switch3State == HIGH && switch4State == HIGH) {
digitalWrite(pin3Output, LOW);
digitalWrite(pin4Output, LOW);
lc.clearDisplay(0);
} else {
// Check if switch 1 and 3 are active
if (switch1State == HIGH && switch3State == HIGH) {
digitalWrite(pin3Output, HIGH);
digitalWrite(pin4Output, LOW);
lc.clearDisplay(0);
} else {
digitalWrite(pin3Output, LOW);
}
// Check if switch 2 and 4 are active
if (switch2State == HIGH && switch4State == HIGH) {
digitalWrite(pin3Output, LOW);
digitalWrite(pin4Output, LOW);
displayArrowRight();
}
}
}
void displayArrowRight() {
byte arrowRight[8] = {
B00011000,
B00001100,
B00000110,
B11111111,
B00000110,
B00001100,
B00011000,
B00000000
};
for (int row = 0; row < 8; row++) {
lc.setRow(0, row, arrowRight[row]);
}
delay(500);
lc.clearDisplay(0);
delay(500);
}
Percobaan 5 Kondisi 1 : Sertakan dengan LM35 dan 7- Segment, ketika suhu bernilai >30 motor searah jarum jam
7. Download File [Kembali]
HTML klik disini
fILE RANGKAIAN klik disini
Video Percobaan klik disini
Listing Program klik disini
datasheet arudino klik disini
Tidak ada komentar:
Posting Komentar