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开发【第六篇】:模块
模块,用一砣代码实现了某个功能的代码集合. 类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合.而对于一个复杂的功能来,可能需要多个函数才 ...
随机推荐
- Swift编程语言学习12 ——实例方法(Instance Methods)和类型方法(Type Methods)
方法是与某些特定类型相关联的函数.类.结构体.枚举都能够定义实例方法:实例方法为给定类型的实例封装了详细的任务与功能.类.结构体.枚举也能够定义类型方法:类型方法与类型本身相关联.类型方法与 Obje ...
- android studio 添加到项目库中的项目
工程-对-new module-Android Library-module name和package name 它应该在同一个库被引入. 然后在该文件夹replace新的library 在gradl ...
- addEventListener 与attachEvent
第一:简单的通用方法(IE && FF) window.onload = function(){ var oDiv = document.getElementById("J_ ...
- Windows系统服务的编写。
实验资源下载地址:点击打开链接 只是不知道能不能从服务向桌面进程传递消息,,就像两个桌面进程之间用Sendmessage似的..希望有知道的大神可以指点一下..不胜感激.. 因为微软在Vista之后, ...
- Codeforces Round #267 (Div. 2)D(DFS+单词hash+简单DP)
D. Fedor and Essay time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 关于Android开发中导出jar包后的资源使用问题解决
我们经常遇到一个需求,就是给别人使用我们工程的时候,为了能够屏蔽代码,把代码封装成jar包提供给第三方使用,但是这样我们的资源文件怎么给对方用呢? 其实并不用这么的复杂,下面就介绍一下具体的方法 一, ...
- PHP调用Webservice实例
原文 PHP调用Webservice实例 NuSoap是PHP环境下的WebService编程工具,用于创建或调用WebService.它是一个开源软件,是完全采用PHP语言编写的.通过HTTP收发S ...
- 使用Dropbox+Justwriting+Markdown建立个人博客
使用Dropbox+Justwriting+Markdown建立个人博客,让您真正体会到什么是"简化". 您的博客所有日志存储在您的PC上.即使有一天你的server主机挂了,你的 ...
- appium之java API(2)
TouchAction AppiumDriver的辅助类,主要针对手势操作,比方滑动.长按.拖动等.TouchAction的原理是讲一系列的动作放在一个链条中,然后将该链条传递给server.serv ...
- php-fpm介绍及配置
php-fpm是什么 全称是php fastcgi process manager即php fastcgi进程管理器,相比fastcgi静态的唤起cgi,fpm能根据访问的压力动态的唤起cgi进程和销 ...