0% found this document useful (0 votes)
13 views3 pages

Arduino

This document is an Arduino sketch for a timer-based game involving a bomb simulation. It uses an LCD to display countdown and status messages, a servo to represent a bomb mechanism, and multiple inputs for cable connections. The game ends when the correct cable is cut, the wrong cable is cut, or the countdown timer reaches zero.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Arduino

This document is an Arduino sketch for a timer-based game involving a bomb simulation. It uses an LCD to display countdown and status messages, a servo to represent a bomb mechanism, and multiple inputs for cable connections. The game ends when the correct cable is cut, the wrong cable is cut, or the countdown timer reaches zero.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include <LiquidCrystal.

h>

#include <Servo.h>

// LCD: RS, E, D4, D5, D6, D7

LiquidCrystal lcd(12, 13, 4, 5, 6, 7);

Int kabelPins[] = {2, 3, 4, 5, 6, 7, 8}; // 7 kabel

Int kabelBenar = 3; // index ke-3 = pin D5

Int buzzerPin = 9;

Int ledHijau = 10;

Int ledMerah = 11;

Servo servo;

Int servoPin = A0; // kamu bisa ganti ke D3 juga

Int posisiServoLedak = 90; // derajat servo saat meledak

Int posisiServoDiam = 0;

Unsigned long countdownTime = 30000;

Unsigned long startTime;

Bool bomAktif = true;

Void setup() {

[Link](16, 2);

[Link](“Pramuka Timer”);

For (int i = 0; i < 7; i++) {

pinMode(kabelPins[i], INPUT_PULLUP);

}
pinMode(buzzerPin, OUTPUT);

pinMode(ledHijau, OUTPUT);

pinMode(ledMerah, OUTPUT);

[Link](servoPin);

[Link](posisiServoDiam);

delay(2000);

startTime = millis();

[Link]();

Void loop() {

If (bomAktif) {

Unsigned long sisa = countdownTime – (millis() – startTime);

[Link](0, 0);

[Link](“Sisa: “);

[Link](sisa / 1000);

[Link](“ detik “);

For (int i = 0; i < 7; i++) {

If (digitalRead(kabelPins[i]) == LOW) {

If (i == kabelBenar) {

[Link](0, 1);

[Link](“Kabel BENAR! “);

digitalWrite(ledHijau, HIGH);

bomAktif = false;

} else {
[Link](0, 1);

[Link](“KABEL SALAH!!! “);

digitalWrite(ledMerah, HIGH);

digitalWrite(buzzerPin, HIGH);

[Link](posisiServoLedak); // servo gerak

bomAktif = false;

If (sisa <= 0) {

[Link](0, 1);

[Link](“WAKTU HABIS!! “);

digitalWrite(ledMerah, HIGH);

digitalWrite(buzzerPin, HIGH);

[Link](posisiServoLedak); // waktu habis → servo gerak

bomAktif = false;

Delay(200);

You might also like