Photocell Tracker Help


hi,

new arduino learning lot in short time have been playing it. 
my project antenna tracker used differently may think.  have photocell measuring amount of light coming in.  if sees no light uses sweep sketch move , forth has antenna attached it.  once photocell detects light servo holds current position.
what , have tried every way once photocell detects no light again.  continue current position sweep.  of right resets starting position , begins sweeping.
i know related "break" command giving in middle of script have tried other commands no success.  appreciated.

code: [select]
// sweep
// barragan <http://barraganstudio.com>
// example code in public domain.


#include <servo.h>

servo myservo;  // create servo object control servo
                // maximum of 8 servo objects can created
int potpin = 0;
int val;
int servo;
int pos = 0;    // variable store servo position

void setup()
{
  myservo.attach(9);  // attaches servo on pin 9 servo object
  serial.begin(9600);
 
}


void loop()
{
  val = analogread(potpin); //read a0 value
  serial.println(val); //display value
  while(val<250) //trigger sweep
  {
 
  for(pos = 20; pos < 160; pos++)  // goes 0 degrees 180 degrees
  {                                  // in steps of 1 degree
    serial.println(val);
    val= analogread(potpin); //read a0 value within while loop
    if(val>450) //value stop sweep
  {break;} //trigger stop sweep
    myservo.write(pos);              // tell servo go position in variable 'pos'
    delay(140);                       // waits 140ms servo reach position
  }
  for(pos = 160; pos >= 20; pos--)  // goes 180 degrees 0 degrees
  {
    serial.println(val);
    val= analogread(potpin);   
    if(val>450)
  {break;}
    myservo.write(pos);              // tell servo go position in variable 'pos'
    delay(140);                       // waits 15ms servo reach position
  }
  }
}

the problem is, algorithm starts search when illumination drops below 250, , happened if light source disappear on left or on right. need modify current hardware setup , implementing "tracking" method. came across project:
http://www.instructables.com/id/arduino-solar-tracker/  which, should give idea


Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > Photocell Tracker Help


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support