Example program for the Seeed Grove shield, that uses Grove Light Sensor by SeeedStudio on A0 pin. This program displays the analog in values.

Dependencies:   mbed

Fork of Seeed_Grove_Shield_Light_Sensor by Shields

Committer:
sam_grove
Date:
Sat Aug 16 00:20:04 2014 +0000
Revision:
2:76004e9cf0cc
Parent:
1:d10e08a99894
Update example for FRDM-KL05Z

Who changed what in which revision?

UserRevisionLine numberNew 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
sam_grove 2:76004e9cf0cc 21 AnalogIn sensor(A1);
screamer 0:5ff78d2c85d1 22 DigitalOut myled(LED1);
screamer 0:5ff78d2c85d1 23
screamer 0:5ff78d2c85d1 24 int main() {
screamer 1:d10e08a99894 25 float val;
screamer 0:5ff78d2c85d1 26 while(1) {
screamer 1:d10e08a99894 27 val = sensor.read();
sam_grove 2:76004e9cf0cc 28 printf("Sensor reading: %2.2f - %2.2f\r\n", val, (float)(1023-val)*10/val);
screamer 0:5ff78d2c85d1 29 myled = !myled;
screamer 0:5ff78d2c85d1 30 wait(0.5);
screamer 0:5ff78d2c85d1 31 }
screamer 0:5ff78d2c85d1 32 }