Hi Everybody, I am Working on a light meter, I have Just "finished it" but I borrowed a real Lux meter and the values I get from the arduino are totally different... the formula I used is one I found in some other post.
This is the code I have used for the lux meter:
#include <ks0108.h> // library for LCD
#include "SystemFont5x7.h" // we need this for character display, included with ks0108.h download
int LDRPINA4 = 5;
int LDRREADING4;
float Resistance = 10.0;
int val = 0;
void setup()
{
GLCD.Init(NON_INVERTED); // load the GLCD library
GLCD.ClearScreen();
GLCD.SelectFont(System5x7); // choose font to use (note this needs to match the #include above
countdown(1);
GLCD.ClearScreen();
GLCD.DrawRect(0, 0, 127, 63,BLACK);
GLCD.CursorTo(1, 1);
// set cursor to top left of LCD (uses character coordinates
// not pixel coordinates
GLCD.Puts(" Welcome To The"); // sends strings to LCD. Does not wrap to next line!
GLCD.CursorTo(1, 2);
GLCD.Puts("#AMAZING LUX METER#");
GLCD.CursorTo(0, 3);
GLCD.Puts("Project Developed by:");
GLCD.CursorTo(1, 4);
GLCD.Puts("Sixto Llorens Zabala");
GLCD.CursorTo(1, 5);
GLCD.Puts("Student No: 08154978");
delay(900);
GLCD.ClearScreen();
GLCD.DrawRect(0, 0, 127, 63,BLACK);
GLCD.CursorTo(1, 1);
GLCD.Puts("Lux Given in Lumens "); // sends strings to LCD. Does not wrap to next line!
GLCD.CursorTo(1, 3);
GLCD.Puts(" LUX\t=");
}
void loop(void)
{
LDRREADING4 = analogRead(LDRPINA4);
float Vout5=LDRREADING4*0.0048828125;
int lux4=104.1*Vout5;
GLCD.CursorTo(12,3);
GLCD.PrintNumber(lux4);
delay(1000);
delay (20);
}
void countdown(int count){
while(count--){ // do countdown
GLCD.CursorTo(10,3); // first column, second row (offset is from 0)
GLCD.PutChar(count + '0');
delay(1000);
}
}
Please can anyone help me on it? can anyone suggest me where I went wrong? or what formula will be giving me the right answer?
By the way, I am using analog input A5... does that affect? This is because in the other posts everybody uses the analog input 0, but because I am using a GLCD my analog input 0 has been used for the screen.
I really want to get this project done as I have been working on it for quite a while now, has anyone attempted it? And got the right values?
Thanks in advance
Sixto
Sorry for my english, Im spanish and I struggle to write it properly