Go Down

Topic: Light Meter Programming (Read 16195 times) previous topic - next topic


I also found this code (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1255287054) which looks to be the best and the exact code I would need for my application but it also just makes the LCD screen go blank for some reason. Can anyone please help me out?

That code has nothing in it that knows anything about your LCD, so it's not surprising that your LCD show nothing.
The art of getting good answers lies in asking good questions.


Thanks for responding. I appreciate it a lot. Now how would I get that code to go with my lcd screen? Is it just a simple edit somewhere in the code and it should work?
This is the LCD screen I have:



I have successfully completed the "Hello World" project from the Arduino website (http://www.arduino.cc/en/Tutorial/LiquidCrystal).

Well, then, you know how to write to the LCD.
The LiquidCrystal class derives from the Print class. So does Serial.

Everywhere that you do a Serial.print(), you can do a lcd.print(), instead, after declaring an instance of LiquidCrystal.
The art of getting good answers lies in asking good questions.


Hi Guys,
Sorry I haven't been back in over a week. I was having some trouble with the lcd screen but it's all set now. Also I have been editing the code to my needs. I have the code working to the best of my knowledge. I was able to compare my light meter design to an actual light meter and the lux readings were close to one another. I do have 1 issue though with my code that I'm hoping I could get some help with. My lux readings display on the lcd screen continually scroll and I would like it to be still but do not know how to edit the code correctly for that. Can anyone help me with that? THANKS! (If someone does respond I won't be able to test it out until Monday.)
 Here is the current code that I'm using which scrolls the results:

int photocellPin0 = 0;     // the cell and 10K pulldown are connected to a0
int photocellReading0;     // the analog reading from the analog resistor divider
float Res0=10.0;              // Resistance in the circuit of sensor 0 (KOhms)
// depending of the Resistance used, you could measure better at dark or at bright conditions.
// you could use a double circuit (using other LDR connected to analog pin 1) to have fun testing the sensors.
// Change the value of Res0 depending of what you use in the circuit
// include the library code:
     #include <LiquidCrystal.h>
     // initialize the library with the numbers of the interface pins
     LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
     int val = 0;
     void setup()
      // set up the LCD's number of columns and rows:
void loop(void) {
 photocellReading0 = analogRead(photocellPin0);   // Read the analogue pin
 float Vout0=photocellReading0*0.0048828125;      // calculate the voltage
 int lux0=104.1*Vout0;           // calculate the Lux
                          // Print the measurement (in Lux units) in the screen
 lcd.print("        Lux\t");
 lcd.print(lux0);               // Print the measured level at pin 0
// turn off automatic scrolling


There is a lcd.setCursor() command that you can use to position the cursor before you write the text. If you add that to loop, the text will always be printed in the same place, so it won't scroll away.
The art of getting good answers lies in asking good questions.



Thanks for the response. Where abouts in the code loop would I add that? Thanks again.


Right before the lcd.print() call.
The art of getting good answers lies in asking good questions.


Hey Guys,

Just letting you know that I got the light meter up and working. I just wanted to thank everyone for all the great help I received here. THANK YOU SO MUCH!

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131