Void myfunction;

Left and Right loops are working fine.....
Forward and Reverse functions are not working.........
Serial monitor says the signal is detected by the board but It dosen`t give any output for forward and reverse loops....
Can any one tell me why is that......!!!

Wheel_Control_firebase_ESP8266.ino (2.89 KB)

Does your code exceed the post limit?
No.
So why didn't you post it?

  Serial.begin(9600);

The stone age is over. Get with the program.

Serial monitor says the signal is detected

I see no proof of that. What signal is supposedly detected?

but It dosen`t give any output for forward and reverse loops....

There are no loops in your code, so the fact that there is no output in the loops is pretty easy to understand.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

Full code here:

#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>

// Set these to run example.
#define FIREBASE_HOST "*****************"
#define FIREBASE_AUTH "********************************"
#define WIFI_SSID "******"
#define WIFI_PASSWORD "********"

#define ENA D7    // ENABLE A
#define INP1 D1   // FORWARD A
#define INP2 D3   // REVERSE A
#define INP3 D4   // FORWARD B
#define INP4 D5   // REVERSE B
#define ENB D8    // ENABLE B
#define t 5      // time interval of data rate

int For = 0;
int Rev = 0;
int Lef = 0;
int Rig = 0;

void setup() {
  Serial.begin(9600);

  pinMode(ENA, OUTPUT);
  pinMode(INP1, OUTPUT);
  pinMode(INP2, OUTPUT);
  pinMode(INP3, OUTPUT);
  pinMode(INP4, OUTPUT);
  pinMode(ENB, OUTPUT);



  // connect to wifi.
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("connecting");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("connected: ");
  Serial.println(WiFi.localIP());

  //Firebase Start
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);

  // update value
  Firebase.setFloat("Wheelchair_Console/number", 1);
  // handle error
  if (Firebase.failed()) {
    Serial.print("setting /number failed:");
    Serial.println(Firebase.error());
    return;
  }
  delay(t);

}

int n = 0;


void loop() {


  Serial.print("Forward: ");
  Serial.println(For = Firebase.getString("control/for").toInt());
  Serial.print("Reverse: ");
  Serial.println(Rev = Firebase.getString("control/backward").toInt());
  Serial.print("Left: ");
  Serial.println(Lef = Firebase.getString("control/lef").toInt());
  Serial.print("Right: ");
  Serial.println(Rig = Firebase.getString("control/right").toInt());

  if (For == 1) {
    forward1();
  }
  if (Rev == 1) {
    reverse1();
  }
  if (Rig == 1) {
    right();
  }
  else if (Lef == 1) {
    turnleft();
  }

  else still();


  delay(t);
}

void still() {

  digitalWrite(ENA, LOW);
  digitalWrite(INP1, LOW);
  digitalWrite(INP2, LOW);
  digitalWrite(INP3, LOW);
  digitalWrite(INP4, LOW);
  digitalWrite(ENB, LOW);

}

void reverse1() {

  digitalWrite(ENA, HIGH);
  digitalWrite(INP1, LOW);
  digitalWrite(INP2, HIGH);
  digitalWrite(INP3, LOW);
  digitalWrite(INP4, HIGH);
  digitalWrite(ENB, HIGH);

}

void turnleft() {

  digitalWrite(ENA, HIGH);
  digitalWrite(INP1, HIGH);
  digitalWrite(INP2, LOW);
  digitalWrite(INP3, LOW);
  digitalWrite(INP4, HIGH);
  digitalWrite(ENB, HIGH);

}

void right() {

  digitalWrite(ENA, HIGH);
  digitalWrite(INP1, LOW);
  digitalWrite(INP2, HIGH);
  digitalWrite(INP3, HIGH);
  digitalWrite(INP4, LOW);
  digitalWrite(ENB, HIGH);

}

void forward1() {

  digitalWrite(ENA, HIGH);
  digitalWrite(INP1, HIGH);
  digitalWrite(INP2, LOW);
  digitalWrite(INP3, HIGH);
  digitalWrite(INP4, LOW);
  digitalWrite(ENB, HIGH);

}

What happens here if For == 1 (and Rev, Rig and Lef are not)?
More importantly: what happens no matter what the value is?

 if (For == 1) {
    forward1();
  }
  if (Rev == 1) {
    reverse1();
  }
  if (Rig == 1) {
    right();
  }
  else if (Lef == 1) {
    turnleft();
  }

  else still();

Adding a couple of elses will fix it.

Hi,
For example with this bit of code.

if (For == 1) {
    forward1();
  }

You do not have a test for when
For == 0 or any other value.

In fact For and other directions could be bool type variables.
This may help.

if (For == 1) {
   forward1();
 }
else
 {
   still();
 }

If For == 0 or any other value except 1 then use still() function.

Tom... :slight_smile: