s 223  Add a comment…  @erchandra56265 months ago Hello sir is robot ki coding de dijiye 🙏❤️ 89 32  @lovewithcode79143 months ago Khud karlo itne to ati hey 7  @jaymahadik16393 months ago 😂😂 2  @luis_rodoble3 months ago @TechXpert-Rohit Yes it is? 5  @akkyzmusica44333 months ago Fukat main thodi milega... 3  @swapnadeepdas11573 months ago (edited) @TechXpert-Rohit Is this code is working? 4  @adamhedhli31253 months ago @TechXpert-Rohit thanks 1  @nicepost15962 months ago Hello sir please robot ka conding dijiye ❤ 1  @saurabhsharma26792 months ago @lovewithcode7914 aati to kyu puchta 1  @saurabhsharma26792 months ago @akkyzmusica4433 koi fokat me hi de de 1  @xerendityapexlegends39402 months ago Might be fake. He can simply code something like "spray water after 10 seconds" and then he puts the burning item in front of the robot after 10 seconds. 1  @abhinavkumar66952 months ago 296527 code 2  @ayushdey54942 months ago @xerendityapexlegends3940 What's that spray after 20 sec ? Do you have any programming knowledge? 1  @CARSEDITZ062 months ago @ayushdey5494 // Include the necessary libraries #include // Define the pins for the flame sensors, motors, and servo const int leftSensor = 9; const int rightSensor = 10; const int forwardSensor = 8; const int leftMotor1 = 2; const int leftMotor2 = 3; const int rightMotor1 = 4; const int rightMotor2 = 5; const int waterPump = 6; const int servoPin = 7; // Adjust the pin number if necessary // Create a servo object Servo myservo; // Declare a boolean variable to track water pump status and fire status bool isWaterPumpOn = false; bool fire = false; // Initialize the flame sensors, motors, and servo void setup() { pinMode(leftSensor, INPUT); pinMode(rightSensor, INPUT); pinMode(forwardSensor, INPUT); pinMode(leftMotor1, OUTPUT); pinMode(leftMotor2, OUTPUT); pinMode(rightMotor1, OUTPUT); pinMode(rightMotor2, OUTPUT); pinMode(waterPump, OUTPUT); // Set the water pump pin as an output // Attach the servo to the pin myservo.attach(servoPin); // Set the initial position of the servo myservo.write(0); } // Loop forever void loop() { // Check if there is fire if (digitalRead(leftSensor) == HIGH || digitalRead(rightSensor) == HIGH || digitalRead(forwardSensor) == HIGH) { fire = true; } else { fire = false; } // If there is fire, move the robot towards it if (fire) { if (digitalRead(leftSensor) == HIGH) { // Turn left digitalWrite(leftMotor1, HIGH); digitalWrite(leftMotor2, LOW); digitalWrite(rightMotor1, LOW); digitalWrite(rightMotor2, HIGH); } else if (digitalRead(rightSensor) == HIGH) { // Turn right digitalWrite(leftMotor1, LOW); digitalWrite(leftMotor2, HIGH); digitalWrite(rightMotor1, HIGH); digitalWrite(rightMotor2, LOW); } else if (digitalRead(forwardSensor) == HIGH) { // Move forward digitalWrite(leftMotor1, HIGH); digitalWrite(leftMotor2, LOW); digitalWrite(rightMotor1, HIGH); digitalWrite(rightMotor2, LOW); } } else { // No fire detected, stop the motors digitalWrite(leftMotor1, LOW); digitalWrite(leftMotor2, LOW); digitalWrite(rightMotor1, LOW); digitalWrite(rightMotor2, LOW); } // If the robot is close to the fire and the left sensor is detecting fire, turn on the water pump and spray water if (fire && (digitalRead(leftSensor) == HIGH || digitalRead(rightSensor) == HIGH || digitalRead(forwardSensor) == HIGH)) { digitalWrite(waterPump, HIGH); isWaterPumpOn = true; // Rotate the servo to spray water at the sight where the fire is detected myservo.write(120); delay(1000); // Delay for spraying water } else { digitalWrite(waterPump, LOW); isWaterPumpOn = false; // Set the servo back to 0 degrees when the fire is extinguished myservo.write(0); } }
Respect, My student trust you. But fire fighting robot not working followed by your circuit diagram and incomplete code. Please don't play with student's expectations. Provide proper coding and circuit diagram.
// Include the necessary libraries #include // Define the pins for the flame sensors, motors, and servo const int leftSensor = 9; const int rightSensor = 10; const int forwardSensor = 8; const int leftMotor1 = 2; const int leftMotor2 = 3; const int rightMotor1 = 4; const int rightMotor2 = 5; const int waterPump = 6; const int servoPin = 7; // Adjust the pin number if necessary // Create a servo object Servo myservo; // Declare a boolean variable to track water pump status and fire status bool isWaterPumpOn = false; bool fire = false; // Initialize the flame sensors, motors, and servo void setup() { pinMode(leftSensor, INPUT); pinMode(rightSensor, INPUT); pinMode(forwardSensor, INPUT); pinMode(leftMotor1, OUTPUT); pinMode(leftMotor2, OUTPUT); pinMode(rightMotor1, OUTPUT); pinMode(rightMotor2, OUTPUT); pinMode(waterPump, OUTPUT); // Set the water pump pin as an output // Attach the servo to the pin myservo.attach(servoPin); // Set the initial position of the servo myservo.write(0); } // Loop forever void loop() { // Check if there is fire if (digitalRead(leftSensor) == HIGH || digitalRead(rightSensor) == HIGH || digitalRead(forwardSensor) == HIGH) { fire = true; } else { fire = false; } // If there is fire, move the robot towards it if (fire) { if (digitalRead(leftSensor) == HIGH) { // Turn left digitalWrite(leftMotor1, HIGH); digitalWrite(leftMotor2, LOW); digitalWrite(rightMotor1, LOW); digitalWrite(rightMotor2, HIGH); } else if (digitalRead(rightSensor) == HIGH) { // Turn right digitalWrite(leftMotor1, LOW); digitalWrite(leftMotor2, HIGH); digitalWrite(rightMotor1, HIGH); digitalWrite(rightMotor2, LOW); } else if (digitalRead(forwardSensor) == HIGH) { // Move forward digitalWrite(leftMotor1, HIGH); digitalWrite(leftMotor2, LOW); digitalWrite(rightMotor1, HIGH); digitalWrite(rightMotor2, LOW); } } else { // No fire detected, stop the motors digitalWrite(leftMotor1, LOW); digitalWrite(leftMotor2, LOW); digitalWrite(rightMotor1, LOW); digitalWrite(rightMotor2, LOW); } // If the robot is close to the fire and the left sensor is detecting fire, turn on the water pump and spray water if (fire && (digitalRead(leftSensor) == HIGH || digitalRead(rightSensor) == HIGH || digitalRead(forwardSensor) == HIGH)) { digitalWrite(waterPump, HIGH); isWaterPumpOn = true; // Rotate the servo to spray water at the sight where the fire is detected myservo.write(120); delay(1000); // Delay for spraying water } else { digitalWrite(waterPump, LOW); isWaterPumpOn = false; // Set the servo back to 0 degrees when the fire is extinguished myservo.write(0); } }