Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of TSL2561_Townsend by
Revision 1:0f3c4d6b818a, committed 2014-01-09
- Comitter:
- anhnt2407
- Date:
- Thu Jan 09 10:18:58 2014 +0000
- Parent:
- 0:9ab53ff6cf89
- Commit message:
- TSL2561(demo program)
Changed in this revision
| TSL2561.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/TSL2561.lib Tue Sep 10 15:15:20 2013 +0000 +++ b/TSL2561.lib Thu Jan 09 10:18:58 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/anhnt2407/code/TSL2561/#df9baf6459b7 +http://mbed.org/users/anhnt2407/code/TSL2561/#ab906ac6e90b
--- a/main.cpp Tue Sep 10 15:15:20 2013 +0000
+++ b/main.cpp Thu Jan 09 10:18:58 2014 +0000
@@ -1,7 +1,6 @@
#include "mbed.h"
#include "TSL2561.h"
-
Serial PC(USBTX, USBRX);
#define PC_PRINTX(z,x) if(z==1) PC.printf(x);
@@ -12,6 +11,9 @@
DigitalOut myled(LED1);
TSL2561 tsl2561(TSL2561_ADDR_FLOAT);
+Timer setuptimer;
+Timer executetimer;
+
void setup(void){
if (tsl2561.begin()) {
@@ -36,8 +38,11 @@
int main() {
PC_PRINTLNX(1,"----------START-------------");
-
+ setuptimer.start();
setup();
+ setuptimer.stop();
+ PC_PRINTLNXY(1,"Setup time: %f",setuptimer.read());
+ setuptimer.reset();
uint16_t x,y,z;
@@ -47,13 +52,18 @@
// Simple data read example. Just read the infrared, fullspecrtrum diode
// or 'visible' (difference between the two) channels.
// This can take 13-402 milliseconds! Uncomment whichever of the following you want to read
+
+ executetimer.start();
x = tsl2561.getLuminosity(TSL2561_VISIBLE);
y = tsl2561.getLuminosity(TSL2561_FULLSPECTRUM);
z = tsl2561.getLuminosity(TSL2561_INFRARED);
+ executetimer.stop();
PC_PRINTLNXY(1,"Visible: %d",x);
PC_PRINTLNXY(1,"Full Spectrum: %d",y);
PC_PRINTLNXY(1,"Infrared: %d",z);
+ PC_PRINTLNXY(1,"Execution Time: %f",executetimer.read());
+ executetimer.reset();
//More advanced data read example. Read 32 bits with top 16 bits IR, bottom 16 bits full spectrum
//That way you can do whatever math and comparisons you want!

Grove Digital Light Sensor