It looks like this one:

This one isn't a digital light sensor, so it's very simple.

http://www.seeedstudio.com/wiki/Grove_-_Light_Sensor

With seeeduino and it's grove shield, this would be very easy to use.

Now we can do a little experiment:

using a LED and a light sensor.

condition 1) If the sensor detects light, the LED will no longer be on. 2) If the sensor detects no light, the LED will be on.

Here is the codes and demo.

codes:

/*
/* Grove - Light Sensor demo v1.0
*
* signal wire to A0.
* By: http://www.seeedstudio.com
*/
#include <math.h>
const int ledPin=; //Connect the LED Grove module to Pin12, Digital 12
const int thresholdvalue=; //The treshold for which the LED should turn on.
float Rsensor; //Resistance of sensor in K
void setup() {
Serial.begin(); //Start the Serial connection
pinMode(ledPin,OUTPUT); //Set the LED on Digital 12 as an OUTPUT
}
void loop() {
int sensorValue = analogRead();
Rsensor=(float)(-sensorValue)*/sensorValue; // using the sensor's analog voltage to caculate the accurate resistance value of it.
if(Rsensor>thresholdvalue) // thresholdvalue = 10 which means if the Rsensor is more than 10K oms (ligth sensor been covered)
{
digitalWrite(ledPin,HIGH); // light sensor covered ==> light on the LED
}
else // light sensor detects light
{
digitalWrite(ledPin,LOW); // light off the LED
}
Serial.println("the analog read data is ");
Serial.println(sensorValue);
Serial.println("the sensor resistance is ");
Serial.println(Rsensor,DEC);//show the ligth intensity on the serial monitor;
delay();
}

Arduino 各种模块篇 光敏感应模块 light sensor的更多相关文章

  1. 「雕爷学编程」Arduino动手做(30)——光敏二极管模块

    37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的.鉴于本人手头积累了一些传感器和模块,依照实践出真知(动手做)的理念,以学习和交流为目的,这里准备逐 ...

  2. 「雕爷学编程」Arduino动手做(17)---人体感应模块

    37款传感器和模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的.鉴于本人手头积累了一些传感器与模块,依照实践出真知(动手试试)的理念,以学习和交流为目的,这里准备 ...

  3. 洗礼灵魂,修炼python(69)--爬虫篇—番外篇之feedparser模块

    feedparser模块 1.简介 feedparser是一个Python的Feed解析库,可以处理RSS ,CDF,Atom .使用它我们可从任何 RSS 或 Atom 订阅源得到标题.链接和文章的 ...

  4. python之常用模块篇5

    一.日志模块,logging模块 1)logging模块简单使用,屏幕输出.默认级别30 import logging logging.debug( logging.info( logging.war ...

  5. Python之路【第七篇】:常用模块

    一. 模块介绍 1. 什么是模块 在前面的几个章节中我们基本上是用 python 解释器来编程,如果你从 Python 解释器退出再进入,那么你定义的所有的方法和变量就都消失了. 为此 Python ...

  6. Python(三)基础篇之「模块&面向对象编程」

    [笔记]Python(三)基础篇之「模块&面向对象编程」 2016-12-07 ZOE    编程之魅  Python Notes: ★ 如果你是第一次阅读,推荐先浏览:[重要公告]文章更新. ...

  7. Python基础篇【第5篇】: Python模块基础(一)

    模块 简介 在计算机程序的开发过程中,随着程序代码越写越多,在一个文件里代码就会越来越长,越来越不容易维护. 为了编写可维护的代码,我们把很多函数分组,分别放到不同的文件里,这样,每个文件包含的代码就 ...

  8. Python之路【第四篇】:模块

    什么是模块: 模块就是一个功能的集合. 模块就和乐高积木差不多,你用这些模块组合出一个模型,然后也可以用这个模块加上其他的模块组合成一个新的模型 模块的种类: 1.内置模块(python自带的比如os ...

  9. Python开发【第六篇】:模块

    模块,用一砣代码实现了某个功能的代码集合. 类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合.而对于一个复杂的功能来,可能需要多个函数才 ...

随机推荐

  1. 随记两个SHELL文本处理

    1,对于AWK通配符的处理 例如文本: AAAAAAAA(CZ航母STYLE+CZ航母STYLE+CZ航母STYLE+CZ航母STYLE);XXXX;CCCCC(F22战机+F22战机);33333( ...

  2. JavaScript重载解读

    在JavaScript有一个特殊的数据类型---Function种类,JavaScript每个功能Function的类型,例如可以.由于函数是对象.指针,不会与某个函数绑定. <pre name ...

  3. linux 下一个 jira-6.3.6 组态 皴 翻译 迁移数据库

    每一个版本号翻译包下载  https://translations.atlassian.com/dashboard/download jira下载地址  https://www.atlassian.c ...

  4. 如何运行代码apk安装

    import java.io.File; import android.app.Activity; import android.content.Intent; import android.net. ...

  5. 用CQRS+ES实现DDD

    用CQRS+ES实现DDD 这篇文章应该算是对前三篇的一个补充,在写之前说个题外话,有园友评论这是在用三层架构在写DDD,我的个人理解DDD是一种设计思想,跟具体用什么架构应该没有什么关系,DDD也需 ...

  6. 快速构建Windows 8风格应用34-构建Toast通知

    原文:快速构建Windows 8风格应用34-构建Toast通知 引言 开发过WindowsPhone应用或者使用过WindowsPhone手机的开发者都知道,我们会收到一些应用的提示信息,这些提示信 ...

  7. 工欲善其事:编辑器之神Vim(一)

    本篇文章收集了Vim最常用和实用的一些命令,掌握这些命令就可以使用Vim了 本文仅列举个人认为常用的命令,本系列文章更像是自己的学习笔记,而不是VIM使用教程. 如果你想了解vim的更多,可以看看Co ...

  8. ReSharper 8.1支持TypeScript语言之代码检查特征

    自ReSharper 8.1发布以来,就支持TypeScript.其在TypeScript语言拼写帮助和代码完成中,几乎是一个里程碑的发展,这是令人激动的改进. 支持TypeScript效果就目前测试 ...

  9. HTML5表单提示placeholder属性兼容IE

    placeholder 属性提供可描述输入字段预期值的提示信息(hint). 该提示会在输入字段为空时显示,并会在字段获得焦点时消失. 注释:placeholder 属性适用于以下的 <inpu ...

  10. CTP API开发期货自动交易平台概论

    题目比较小众,先介绍一下CTP. 综合交易平台CTP(Comprehensive Transaction Platform)是由上海期货信息技术有限公司(上海期货交易所的全资子公司)开发的期货交易平台 ...