Langkah-langkah percobaan :
1. Siapkan alat dan bahan yaitu dengan komponen utama Arduino Uno, Infrared Sensor, IC I2C, Keypad dan Motor DC
2. Rangkai sesuai gambar percobaan
3. Rancang kerja rangkaian sesuai flowchart
4. Tekan tombol “Play” untuk menjalankan simulasi
2. Hardware dan Diagram Blok [Kembali]
- Infrared sensor
- Arduino
- LCD
- Keypad
- Motor
3. Rangkaian Simulasi dan Prinsip Kerja [Kembali]
Prinsip Kerja:
Semua sakelar pull down di sirkuit ini. Jika sakelar 1 dan 3 hidup, motor akan berputar ke kiri; jika sakelar 2 dan 4 hidup, motor akan berputar ke kanan.
4. Flowchart dan Listing Program [Kembali]
flowchart:
listing program:
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 = 3; // Output pin connected to pin 3
const int pin4Output = 4; // Output pin connected to pin 4
void setup() {
pinMode(switch1Pin, INPUT); // Set switch 1 pin as input
pinMode(switch2Pin, INPUT); // Set switch 2 pin as input
pinMode(switch3Pin, INPUT); // Set switch 3 pin as input
pinMode(switch4Pin, INPUT); // Set switch 4 pin as input
pinMode(pin3Output, OUTPUT); // Set pin 3 output pin
pinMode(pin4Output, OUTPUT); // Set pin 4 output pin
}
void loop() {
// Read the state of all switches
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); // Set pin 3 output to LOW
digitalWrite(pin4Output, LOW); // Set pin 4 output to LOW
} else {
// Check if switch 1 and switch 3 are pressed
if (switch1State == HIGH && switch3State == HIGH) {
digitalWrite(pin3Output, HIGH); // Set pin 3 output to HIGH
} else {
digitalWrite(pin3Output, LOW); // Set pin 3 output to LOW
}
// Check if switch 2 and switch 4 are pressed
if (switch2State == HIGH && switch4State == HIGH) {
digitalWrite(pin4Output, HIGH); // Set pin 4 output to HIGH
} else {
digitalWrite(pin4Output, LOW); // Set pin 4 output to LOW
}
}
}
5. Kondisi [Kembali]
Kondisi 3:
Semua Switch pull-down, switch 1 dan 3 motor ke kiri, switch 2 dan 4 panah ke kanan dan motor ke kananD
7. Download File [Kembali]
video klik di sini
html klik di sini
rangkaian klik di sini
code arduino uno klik di sini
Tidak ada komentar:
Posting Komentar