Skip to content

Commit

Permalink
Update code-v2.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
fajarjulyana authored Apr 2, 2023
1 parent 6758f39 commit a714326
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion src/code-v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,60 @@ void loop() {

// cek apakah ada barang yang diangkut

if (red > red_threshold && green > green_threshold && blue > blue_threshold
if (red > red_threshold && green > green_threshold && blue > blue_threshold) {

// jika ada barang, angkat forklift

forklift.write(90);

delay(500);

// maju ke titik B

motor_A.forward();

motor_B.forward();

delay(3000);

// turunkan forklift

forklift.write(0);

delay(500);

// mundur ke titik A

motor_A.reverse();

motor_B.reverse();

delay(3000);

// hentikan motor DC

motor_A.stop();

motor_B.stop();

} else {

// jika tidak ada barang, maju ke titik B dan kembali ke titik A tanpa angkat forklift

motor_A.forward();

motor_B.forward();

delay(3000);

motor_A.reverse();

motor_B.reverse();

delay(3000);

motor_A.stop();

motor_B.stop();
}
}

0 comments on commit a714326

Please sign in to comment.