Show Posts
Pages: 1 ... 3 4 [5]
61  Using Arduino / General Electronics / Re: Help needed with my IR sensor for line follower... on: February 21, 2011, 03:23:16 am
Groove, if you would please read the query once again! its not the same question i posted. last one i posted was regarding the compiler error , and this time the sensors were giving wrong data, and i wanted to know why..

when both the sensors were above a white surface, they both should have been giving a low analog input, but i checked serial monitor (NOT WITH THE ABOVE PROGRAM), but one gave around 385 and other gave around 50..
hope i made my point..
62  Using Arduino / General Electronics / Re: Help needed with my IR sensor for line follower... on: February 20, 2011, 11:26:34 am
heres the code -


  int leftmotor1=1;
 int leftmotor2=2;
   int rightmotor1=3;
 int rightmotor2=4;
 int leftsensor=A0;
 int rightsensor=A2;
 

void setup()
{
  pinMode(A0, INPUT);
  pinMode(A2, INPUT);
  pinMode(1,OUTPUT);
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
   
 
}

void right()
{
  digitalWrite(leftmotor1, HIGH);
  digitalWrite(leftmotor2, LOW);
}

void left()
{
  digitalWrite(rightmotor1, LOW);
  digitalWrite(rightmotor2, HIGH);
}
 
void straight()
{
  digitalWrite(leftmotor1, HIGH);
  digitalWrite(leftmotor2, LOW);
  digitalWrite(rightmotor1, LOW);
  digitalWrite(rightmotor2, HIGH);
}
 
void loop()
{
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  if( analogRead(leftsensor<400 && rightsensor<400))
  {
    straight();
  }
  else if( analogRead(leftsensor>400 && rightsensor<400))
  {
    left();
  }
  else if( analogRead(leftsensor>400 && rightsensor>400))
  {
    right();
   
  }
}
63  Using Arduino / General Electronics / Help needed with my IR sensor for line follower... on: February 20, 2011, 07:08:58 am
Hey im using 2 infra red sensors for my line follower robot. I placed both the sensors on white ground, but i got a low value for my left sensor and high value for the right sensor(checked through serial monitor).. It should have been equal. when i interchanged the ports , the left sensor gave high and right sensor gave low. what is happening? please help..
64  Using Arduino / Programming Questions / Re: help for line follower code! on: February 19, 2011, 12:08:15 pm
hmm... what exactly is wrong, there?
65  Using Arduino / Programming Questions / help for line follower code! on: February 19, 2011, 12:02:36 pm
Im new to arduino programming and ive been facing some problem compiling my code for a line follower that uses 2 infra red sensors ....
heres the code,


int leftmotor1=1;
 int leftmotor2=2;
   int rightmotor1=3;
 int rightmotor2=4;
 int leftsensor=A0;
 int rightsensor=A2;
 

void setup()
{
  pinMode(A0, INPUT);
  pinMode(A2, INPUT);
  pinMode(1,OUTPUT);
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
   
 
}

void right()
{
  digitalWrite(leftmotor1, HIGH);
  digitalWrite(leftmotor2, LOW);
}

void left()
{
  digitalWrite(rightmotor1, LOW);
  digitalWrite(rightmotor2, HIGH);
}
 
void straight()
{
  digitalWrite(leftmotor1, HIGH);
  digitalWrite(leftmotor2, LOW);
  digitalWrite(rightmotor1, LOW);
  digitalWrite(rightmotor2, HIGH);
}
 
void loop()
{
  if( analogRead(leftsensor<400 && rightsensor<400))
  {
    straight();
  }
  else if( analogRead(leftsensor>400 && rightsensor<400))
  {
    left();
  }
  else( analogRead(leftsensor>400 && rightsensor>400))
  {
    right();
   
  }
}

the error comes in the loop function. please help smiley
Pages: 1 ... 3 4 [5]