Skip to content

Instantly share code, notes, and snippets.

@e-Gizmo
Created June 10, 2019 08:58
Show Gist options
  • Save e-Gizmo/e3242f5a0d259222506f3ce2954e5844 to your computer and use it in GitHub Desktop.
Save e-Gizmo/e3242f5a0d259222506f3ce2954e5844 to your computer and use it in GitHub Desktop.
Another example for FireFighterFan to SearchFire.
int DCMOTOR = 4;
int PWM_SPEED = 100;
int SPEED_MOTOR = 150;
boolean fire = false;
boolean search = false;
int DELAY = 100;
void setup() {
// put your setup code here, to run once:
pinMode(DCMOTOR, OUTPUT);
// FLAME SENSORS
pinMode(5, INPUT); //FS_RIGHT
pinMode(6, INPUT); //FS_CENTER
pinMode(7, INPUT); //FS_LEFT
//MOTOR PINS
pinMode(8, OUTPUT); //dirmotor1
pinMode(9, OUTPUT); //spdmotor1
pinMode(10, OUTPUT); //spdmotor2
pinMode(11, OUTPUT); //dirmotor2
}
void loop() {
// put your main code here, to run repeatedly:
int FLAME_CENTER = digitalRead(6);
TURN_RIGHT();
if (FLAME_CENTER == 0) {
STOP();
PUT_OFF_FIRE();
}
}
void PUT_OFF_FIRE() {
STOP();
delay(1000);
// digitalWrite(RELAY_DC, HIGH);
digitalWrite(DCMOTOR, HIGH);
delay(5000);
digitalWrite(DCMOTOR, LOW);
delay(1000);
}
void FORWARD() {
digitalWrite(8, HIGH);
analogWrite(9, SPEED_MOTOR);
analogWrite(10, SPEED_MOTOR);
digitalWrite(11, HIGH);
}
void TURN_RIGHT() {
digitalWrite(8, HIGH);
analogWrite(9, SPEED_MOTOR);
analogWrite(10, SPEED_MOTOR);
digitalWrite(11, LOW);
}
void TURN_LEFT() {
digitalWrite(8, LOW);
analogWrite(9, SPEED_MOTOR);
analogWrite(10, SPEED_MOTOR);
digitalWrite(11, HIGH);
}
void STOP() {
//digitalWrite(8, HIGH);
analogWrite(9, 0);
analogWrite(10, 0);
//digitalWrite(11, HIGH);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment