![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Lights up to 4 LEDs based on ambient light levels. Uses Grove Seeed Light Sensor
Fork of Seeed_Grove_Shield_Light_Sensor by
main.cpp@0:5ff78d2c85d1, 2014-07-29 (annotated)
- Committer:
- screamer
- Date:
- Tue Jul 29 13:23:29 2014 +0000
- Revision:
- 0:5ff78d2c85d1
- Child:
- 1:d10e08a99894
Initial revision
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
screamer | 0:5ff78d2c85d1 | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
screamer | 0:5ff78d2c85d1 | 2 | * |
screamer | 0:5ff78d2c85d1 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
screamer | 0:5ff78d2c85d1 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
screamer | 0:5ff78d2c85d1 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
screamer | 0:5ff78d2c85d1 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
screamer | 0:5ff78d2c85d1 | 7 | * Software is furnished to do so, subject to the following conditions: |
screamer | 0:5ff78d2c85d1 | 8 | * |
screamer | 0:5ff78d2c85d1 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
screamer | 0:5ff78d2c85d1 | 10 | * substantial portions of the Software. |
screamer | 0:5ff78d2c85d1 | 11 | * |
screamer | 0:5ff78d2c85d1 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
screamer | 0:5ff78d2c85d1 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
screamer | 0:5ff78d2c85d1 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
screamer | 0:5ff78d2c85d1 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
screamer | 0:5ff78d2c85d1 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
screamer | 0:5ff78d2c85d1 | 17 | */ |
screamer | 0:5ff78d2c85d1 | 18 | |
screamer | 0:5ff78d2c85d1 | 19 | #include "mbed.h" |
screamer | 0:5ff78d2c85d1 | 20 | |
screamer | 0:5ff78d2c85d1 | 21 | AnalogIn sensor(A0); |
screamer | 0:5ff78d2c85d1 | 22 | DigitalOut myled(LED1); |
screamer | 0:5ff78d2c85d1 | 23 | |
screamer | 0:5ff78d2c85d1 | 24 | Serial pc(USBTX, USBRX); |
screamer | 0:5ff78d2c85d1 | 25 | |
screamer | 0:5ff78d2c85d1 | 26 | int main() { |
screamer | 0:5ff78d2c85d1 | 27 | while(1) { |
screamer | 0:5ff78d2c85d1 | 28 | printf("Sensor reading: %f\r\n", (float)(1023-sensor)*10/sensor); |
screamer | 0:5ff78d2c85d1 | 29 | myled = !myled; |
screamer | 0:5ff78d2c85d1 | 30 | wait(0.5); |
screamer | 0:5ff78d2c85d1 | 31 | } |
screamer | 0:5ff78d2c85d1 | 32 | } |