Light Meter Programming

Discussion in 'Embedded Systems and Microcontrollers' started by heberjm8, Nov 6, 2010.

  1. heberjm8

    Thread Starter New Member

    Oct 7, 2010
    11
    0
    Hello,

    I’m hoping I can obtain some much needed help with the programming of a circuit. I have never programmed before so this is all new to me. Well I’m designing an ambient light sensor with a digital display showing the amount of lux detected. So pretty much, just a basic light meter with a digital display for the lux. Looking at other light meters on the market I believe I want the lux range to be from 0 to anywhere to 20k, 40k, 50k, or even 100k lux. The max lux range really doesn’t matter as long as it’s sufficient enough. With the help of a customer service member I have already ordered the main parts I believe I’ll need for this circuit. Those parts being a photocell, a LCD screen (HD44780 chipset), and a micro-controller(Arduino Uno). I already have a breadboard, resistors, etc. If someone would be so kind to help me out by telling me how the easiest way to start constructing and programming this circuit I would greatly appreciate it. Diagrams or similar projects with my components would be great too. Thanks again.

    Here are the web pages to the parts I have ordered so far:

    (Photocell)

    http://www.sparkfun.com/commerce/product_info.php?products_id=9088

    (LCD Screen)

    https://www.sparkfun.com/commerce/product_info.php?products_id=709

    (Micro-controller)

    http://www.sparkfun.com/commerce/product_info.php?products_id=9950
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
  3. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
  4. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
  5. heberjm8

    Thread Starter New Member

    Oct 7, 2010
    11
    0
    Thanks for all the responses everyone. I appreciate it a lot.

    Yes I have downloaded the Arduino IDE. Thanks.

    Now I need to know how the display screen and the micro-controller go together. I'm thinking it shouldn't be that difficult but I'm not exactly sure.

    What I really need is a program or a how to that will be able to use my photocell to display the LUX on the digital screen.

    P.S. I also have this photocell (The webpage is below for it). I'm not sure if it will be easier to use or not but I thought I'd mention it.
    http://www.datasheetcatalog.org/datasheet/BurrBrown/mXqyxtx.pdf
     
  6. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    If you look in the Arduino IDE you will find an example program for LCD character display program. That will get you started.

    hgmjr
     
  7. heberjm8

    Thread Starter New Member

    Oct 7, 2010
    11
    0
    I have done a lot more research about programming and feel more comfortable with the terms now. I have my arduino board and my computer up and now communicating. Anyways, I was wondering if someone could send me or create a similar code for my design (light meter displaying the amount of lux on a lcd screen) that I could edit to my needs. I haven't been able to find a good code to start with yet, so I'm hoping someone can help me out with that. I appreciate your help so much. THANKS!!!
     
  8. bertus

    Administrator

    Apr 5, 2008
    15,649
    2,348
  9. GetDeviceInfo

    Senior Member

    Jun 7, 2009
    1,571
    230


    You might want to define that a bit better, then check your sensors range.
     
  10. heberjm8

    Thread Starter New Member

    Oct 7, 2010
    11
    0
    Hey,

    I'm hoping someone here could help me out. I have a question about the coding. I've attached a video and code for a light meter below. I was wondering if you could tell me for that code that someone has posted if that's all the code you need for it to work. I was talking to someone at school today about it and he wasn't sure but he was telling me about how that's not an entire code. (Even though the person who posted it said it was.) He talked about the beginning of the code and how it starts with "Serial.begin (9600) " He was telling me there is a code for that alone and I would need it along with the code that got posted. Something about a library code. I was confused with what he was saying. To me it looks like an entire code but then again I don't really know nothing about coding. Can you clear anything up for me? Thanks!!!


    http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1202530375

    http://www.youtube.com/watch?v=H1wwhJlwnWg
     
  11. GetDeviceInfo

    Senior Member

    Jun 7, 2009
    1,571
    230
    he's correct, you have a few library calls you need to link. You also need a 'main' routine to kick things off, a way to get in and a way to get out of your code snippet.
     
  12. heberjm8

    Thread Starter New Member

    Oct 7, 2010
    11
    0
    Okay so I’ve made some great progress on my light meter since I last posted. I have successfully completed the “Hello World” project from the Arduino website (http://www.arduino.cc/en/Tutorial/LiquidCrystal). I’ve got the Arduino board communicating with the computer and now the LCD screen is correctly displaying the information. I have attached a picture of my project so you can see it. I feel like I’m almost there which feels great!

    My last 2 parts I need to complete is hooking up the photocell that I have (http://www.sparkfun.com/products/9088) to the Arduino board and obtaining the right code so the LCD will display the amount of lux. Well I was able to find a few codes online and try them out but they did not work. Here is one of them I tried:

    http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1202530375
    http://www.youtube.com/watch?v=H1wwhJlwnWg

    The two links go together. The video is of that particular code working. I know this code does not display the amount of lux but it does display 4 different light conditions (pretty dark, dark, bright, pretty bright). I just wanted to see my photocell in action displaying the light conditions on my lcd screen. When I hooked up the photocell and uploaded the code my lcd screen just went blank for some reason. This is how I hooked up the photocell which I found on a different webpage:

    5V >--[ Photocell ]---+---[ 10k Ohm ]---< GND
    |
    Arduino pin A0

    I tried resetting the board and uploading the code many times. I also uploaded the “Hello World” code in between testing and that would work perfectly every time. So the possible 2 issues I think I’m having are that I do not know the type of photocell the person used or how exactly he hooked up the photocell. Even if I didn’t know his exact photocell he used I’m thinking I should still be able to see a light condition being displayed on my lcd even if it’s a wrong light condition.

    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? I would so greatly appreciate it. THANK YOU SO MUCH!
     
  13. heberjm8

    Thread Starter New Member

    Oct 7, 2010
    11
    0
    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!
     
Loading...