loading

I can not write English, this is all from the Netherlands to the English translated by google translator

what did you make
I'm so finicking that the brightest light point with 1 search ldr.
in the future for me to serve a solar panel toward the sun to set.
Therefore it must be the brightest light point and can not follow

how did you make
I saw that an old student in school for his thesis a solar panel that has made them turned to the sun.
so I thought that I could make, I've been looking on youtube and instructables for similar projects. but there was not how I imagined me.
it was all with 2 or more ldr, 1left 1 right 1TOP 1 downstairs.
and which are moved all the time to to adjust.
and so I came up with the idea to do it with 1 ldr

whare did you make it
I made it home

what did you learn 
I've learned to work with array.
to the analog number to be stored
and on the SD card to store.

I put this on instructables for that I've learned a lot from the whole "Open Sorce" thing

and if you really want to make something you just have to try

Step 1: Component List

I can not write English, this is all from the Netherlands to the English translated by google translator

list
2 servo
1 ldr
1 10k resistance
1 SD card module
1 arduino

Step 2: Make Sero Tilt Pan

 I can not write English, this is all from the Netherlands to the English translated by google translator

 here is a link to how I did mine I put together
http://iprototype.be/docs/pan-tilt-montage-tutorial.pdf

Step 3: Connecting to Arduino

servo 1  to pin 5
servo 2 to pin 6

ldr to analoge pin 0

SD card
MOSI = Pin 11
MISO = Pin 12
SCLK = PIN 13
CS_pin = 10;

Step 4: Code

I can not write English, this is all from the Netherlands to the English translated by google translator

the servo 180 steps and run every 5 steps ldr analog read store in array

for (int pos0 = 0;pos0<=181;pos0++)
{
richtingservo.write(plaats[pos0]);

if ( pos0 % 5 == 0) // pos0 delen door 5 en als de rest 0 is dan is het op 0,5,10,15,...

delay(300);
val = analogRead(ldr);     // meten van de licht waarden
licht[i]=val;   // licht waarden stokeren in array
Serial.print("ldr "); Serial.print(i); Serial.print(" "); Serial.println(val);
i++;
  }


the more light the lower the analog read is
find the lowest number in the array and go to the place where it is


for(int a=0;a<37;a++)
{
if (licht[a] <= j)
{
j = licht[a];
posplaats = a; 
posplaats = posplaats *5;
Serial.println(posplaats);

}}

richtingservo.write(180);

  for (int e=180;e>posplaats;e--)
  {
  richtingservo.write(plaats[e]);
  delay(120);
  }

Create a file on the SD card.
and the value of the analog read store the card


File dataFile = SD.open("log.txt", FILE_WRITE);
  if (dataFile)
  {
    int data = analogRead(0);
   
    dataFile.println(data);
    dataFile.close();
    Serial.println(data);
  }

Step 5: Complete Code

#include <SD.h>
//Set by default for the SD Card Library
//MOSI = Pin 11
//MISO = Pin 12
//SCLK = PIN 13
//We always need to set the CS Pin
int CS_pin = 10;


#include <Servo.h>
Servo richtingservo; // servo 1
Servo hoekservo;     // servo 2

int ldr = 0;// analogpin 0
int val;
int j;

int posplaats;
int hoek;

int licht[38];

int ldrhoek[19];


// een array van 181
int plaats[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,
18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,
36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,
54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,
72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,
90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,
106,107,108,109,110,111,112,113,114,115,116,117,118,119,
120,121,122,123,124,125,126,127,128,129,130,131,132,
133,134,135,136,137,138,139,140,141,142,143,144,145,
146,147,148,149,150,151,152,153,154,155,156,157,158,
159,160,161,162,163,164,165,166,167,168,169,170,171,
172,173,174,175,176,177,178,179,180};


int lichthoek[]={30,31,32,33,34,35,36,37,38,39,40,41,
42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,
59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,
76,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,
94,95,96,97,98,99,100,101,102,103,104,105};






void setup ()
{
richtingservo.attach(5);
hoekservo.attach(6);
Serial.begin(9600);

richtingservo.write(0);
hoekservo.write(70);

//CS Pin is an output
  pinMode(CS_pin, OUTPUT);
if (!SD.begin(CS_pin))
  {
      Serial.println("Card Failure");
      return;
  }
  Serial.println("Card Ready");
}

void loop ()
{
  if (posplaats!=0)
  {
  for (int t = posplaats;t>0;t--)
  {
  richtingservo.write(t);
  Serial.print("posplaats  "); Serial.println(t);
  delay(120);
  }
  }
 

val = analogRead(ldr);
j = analogRead(ldr);

int i =0; // elke keer terug op nul voor licht array waarden

  // servo posietie juist zetten en licht array vullen met de waarden
for (int pos0 = 0;pos0<=181;pos0++)
{
richtingservo.write(plaats[pos0]);

if ( pos0 % 5 == 0) // pos0 delen door 5 en als de rest 0 is dan is het op 0,5,10,15,...

delay(300);
val = analogRead(ldr);     // meten van de licht waarden
licht[i]=val;   // licht waarden stokeren in array
Serial.print("ldr "); Serial.print(i); Serial.print(" "); Serial.println(val);
i++;
  }

if (richtingservo.read()==180)
{break;}

delay(170);
}


  richtingservo.write(180);
 
val = analogRead(ldr);
j = analogRead(ldr);

  // grootste licht waarden zoeken en in j plaatsen 
  for(int a=0;a<37;a++)
{
if (licht[a] <= j)
{
j = licht[a];
posplaats = a; 
posplaats = posplaats *5;
Serial.println(posplaats);

}}

richtingservo.write(180);

  for (int e=180;e>posplaats;e--)
  {
  richtingservo.write(plaats[e]);
  delay(120);
  }
 
 
  //jmkhhhhhhhhhhhhhhhhhhhjkujkjfiejfknjdfq kmdsjf
 

val = analogRead(ldr);
j = analogRead(ldr);
int y = 0;
 
for(int pos1=0;pos1<75;pos1++)
{
hoekservo.write(lichthoek[pos1]);     // servo zeten op de plaat voor licht waarden te meten

if (pos1 % 5 == 0)
{
delay(300);
val = analogRead(ldr);          // meten van de licht waarden
ldrhoek[y]=val;              // licht waarden stokeren in array
Serial.print("ldr hoek "); Serial.print(y); Serial.print("  "); Serial.println(val);
y++;
}

if (richtingservo.read()==105)
{break;}

delay(200);

}

  for(int z=0;z<15;z++)
{
if (ldrhoek[z] <= j)
{
j = ldrhoek[z];
hoek = z;
hoek = hoek *5;
Serial.println(hoek);
}}

hoekservo.write(105);
 
hoekservo.write(lichthoek[hoek]);
 
  File dataFile = SD.open("log.txt", FILE_WRITE);
  if (dataFile)
  {
    int data = analogRead(0);
   
    dataFile.println(data);
    dataFile.close();
    Serial.println(data);
  }
  else
  {
    Serial.println("Couldn't open log file");
  }
 
  delay(5000);
 
 
}
<p>very cool !</p>
Man, I respect your attempt at English and your idea is great

About This Instructable

2,392views

10favorites

License:

More by DKN:light detection + data logging white arduino 
Add instructable to: