Hi all,

I'm looking to use Digilent's Ambient Light Sensor as an add-on for a project I'm doing. I can't use the example code given because I'm using a little bit more complex of a coding environment (Eclipse). I've managed to translate so to speak most of the example code to work for my environment, but one thing I'm struggling with is creating the correct initialization code in my environment. Does anyone have any experience coding the ALS outside of an Arduino-like environment  or can tell me what I need to do to initialize it correctly?


Share this post

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 1

Hello Lia,

Looking through the example code, there isn't really any initialization for the ALS sensor itself.  Just read from the SPI port, 16-bits at a time, and it'll set itself up.

The trick remaining is on your platform as you set up the interaction with the PMod SPI.  You need to set it up so that the clock is 2MHz (as per the example), and the transfer size 16 bits.  This should be sufficient setup, but how to do it is dependent upon the platform you are using.  You may also notice, in the example code, that the chip-select line, sometimes called SS, needs to be pulled low before the 16-bit transfer and brought high again afterwards.  Depending upon how your SPI port works, this may or may not be an automatic part of your SPI port.

Without knowing the platform you are using, though, or how you are struggling with it--it may be difficult to offer any more help.


Share this post

Link to post
Share on other sites
  • 0

Hi Dan,

I'm using a version of Eclipse IDE that's tailored towards my board. Your answer was perfect and told me everything I needed. I'm still working out the clock timing (the given line of code in Eclipse I'm using is a bit hard to read) but I have everything else you mentioned already implemented in my code. Thanks so much for the help!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now