Arduino 各种模块篇 光敏感应模块 light sensor
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的更多相关文章
- 「雕爷学编程」Arduino动手做(30)——光敏二极管模块
37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的.鉴于本人手头积累了一些传感器和模块,依照实践出真知(动手做)的理念,以学习和交流为目的,这里准备逐 ...
- 「雕爷学编程」Arduino动手做(17)---人体感应模块
37款传感器和模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的.鉴于本人手头积累了一些传感器与模块,依照实践出真知(动手试试)的理念,以学习和交流为目的,这里准备 ...
- 洗礼灵魂,修炼python(69)--爬虫篇—番外篇之feedparser模块
feedparser模块 1.简介 feedparser是一个Python的Feed解析库,可以处理RSS ,CDF,Atom .使用它我们可从任何 RSS 或 Atom 订阅源得到标题.链接和文章的 ...
- python之常用模块篇5
一.日志模块,logging模块 1)logging模块简单使用,屏幕输出.默认级别30 import logging logging.debug( logging.info( logging.war ...
- Python之路【第七篇】:常用模块
一. 模块介绍 1. 什么是模块 在前面的几个章节中我们基本上是用 python 解释器来编程,如果你从 Python 解释器退出再进入,那么你定义的所有的方法和变量就都消失了. 为此 Python ...
- Python(三)基础篇之「模块&面向对象编程」
[笔记]Python(三)基础篇之「模块&面向对象编程」 2016-12-07 ZOE 编程之魅 Python Notes: ★ 如果你是第一次阅读,推荐先浏览:[重要公告]文章更新. ...
- Python基础篇【第5篇】: Python模块基础(一)
模块 简介 在计算机程序的开发过程中,随着程序代码越写越多,在一个文件里代码就会越来越长,越来越不容易维护. 为了编写可维护的代码,我们把很多函数分组,分别放到不同的文件里,这样,每个文件包含的代码就 ...
- Python之路【第四篇】:模块
什么是模块: 模块就是一个功能的集合. 模块就和乐高积木差不多,你用这些模块组合出一个模型,然后也可以用这个模块加上其他的模块组合成一个新的模型 模块的种类: 1.内置模块(python自带的比如os ...
- Python开发【第六篇】:模块
模块,用一砣代码实现了某个功能的代码集合. 类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合.而对于一个复杂的功能来,可能需要多个函数才 ...
随机推荐
- 自动引用计数(ARC)
1.1什么是自动引用技术 顾名思义,自动引用计数(ARC, Automatic Reference Counting)是指内存管理中对引用采取自动计数的技术.以下摘自苹果官方说明: 在Objectiv ...
- Android安卓安全审计mobiseclab
关于安卓上的app分析,有非常多的本地化软件能够胜任, 只是,今天给大家介绍一款在线的安全审计,恶意软件(android app)检測和分析工具,mobiseclab, 由于看到国内对此工具的介绍比較 ...
- 关于Java中List对象的分页思想,按10个或者n个数对list进行分组
try { List<String> timelist = DateUtils.getDateListBySETime("2015-08-01", "2015 ...
- c#登录时保存账号密码到cookie
登陆界面有用户名.密码输入框,一个’记住账号密码‘的复选框. 1.登录时,勾选‘记住账号密码‘复选框,则会把用户名密码保存在客户端cookie里,保存时间为最大值(直到用户清除浏览器缓存或者取消勾选’ ...
- uva 11181 - Probability|Given
条件概率公式:P( A|B ) = P( AB ) / P( B ) 表示在事件B发生的前提,事件A发生的可能性: 问题的: 复位事件E:r个人买东西: 事件Ei:文章i个人买东西: 的要求是P( E ...
- [译]JDK 6 and JDK 7中的subString()方法
(说明,该文章翻译自The substring() Method in JDK 6 and JDK 7) 在JDK 6 and JDK 7中的substring(int beginIndex, int ...
- [译]Java 垃圾回收介绍
说明:这篇文章来翻译来自于Javapapers 的Java Garbage Collection Introduction 在Java中,对象内存空间的分配与回收是由JVM中的垃圾回收进程自动完成的. ...
- css @media认识
css2的@media css2里面尽管支持@media属性.可是能实现的功能比較少,一般仅仅用做打印的时候做特殊定义的CSS. 语法: @media sMedia { sRules } 说明: sM ...
- nginx 502 Bad Gateway 错误问题收集
nginx 502 Bad Gateway 错误问题收集 (2010-11-18 13:51:37) 转载▼ 标签: 杂谈 分类: 工作 nginx 502 Bad Gateway 错误问题收集 因为 ...
- 【转】【Android UI设计与开发】第07期:底部菜单栏(二)Fragment的详细介绍和使用方法
原始地址:http://blog.csdn.net/yangyu20121224/article/category/1431917/1 由于TabActivity在Android4.0以后已经被完全弃 ...