Pages: 1 [2]   Go Down
Author Topic: Light Meter Programming  (Read 5783 times)
0 Members and 1 Guest are viewing this topic.
Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48569
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
https://www.sparkfun.com/products/709

THANKS AGAIN!!!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48569
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
        lcd.begin(16,1);
      }
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
  delay(100);
// turn off automatic scrolling
  lcd.noAutoscroll();
}  
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48569
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Paul,

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48569
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Right before the lcd.print() call.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Pages: 1 [2]   Go Up
Jump to: