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开发【第六篇】:模块
模块,用一砣代码实现了某个功能的代码集合. 类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合.而对于一个复杂的功能来,可能需要多个函数才 ...
随机推荐
- C语言库函数大全及应用实例二
原文:C语言库函数大全及应用实例二 [编程资料]C语言库函数大全及应用实例二 函数名: bioskey 功 能 ...
- 关于WIN32.EXE变态木马下载器的解决办法
一.WIN32.EXE的来源:http://fdghewrtewrtyrew.biz/adv/130/win32.exe 二.运行后的表现:此WIN32.EXE通过80和8080端口访问若干个IP,若 ...
- 分区表在安装系统(MBR)丢失或损坏
操作系统能识别出硬盘中的各个不同的分区,是靠硬盘分区表(MBR)来识别的. 硬盘分区表中记录了各个分区的位置和大小以及类型等信息,假设这个分区表破坏了,那么这块硬盘里面的分区就会丢失.系统是无法在浏览 ...
- SQL点滴8—the account is currently locked out. The system administrator can unlock it.
原文:SQL点滴8-the account is currently locked out. The system administrator can unlock it. 今天遇到的问题比较有意思. ...
- wsgi-restful-routes具体解释:
感谢朋友支持本博客,欢迎共同探讨交流,因为能力和时间有限,错误之处在所难免,欢迎指正! 如有转载,请保留源作者博客信息. Better Me的博客:blog.csdn.net/tantexian 如需 ...
- Java凝视Override、Deprecated、SuppressWarnings详细解释
一.什么是视线 说起目光,你必须先提什么是元数据(metadata). 所谓元数据是数据的数据.那.元数据是描述数据的叙述. 像在表中的数据字段,叙述了这个字段下的数据的含义.而J2SE5.0 ...
- 【转】android创建Popwindow弹出菜单的两种方式
方法一的Activity package com.app.test02; import android.app.Activity; import android.os.Bundle; import a ...
- jquery插件推荐
jQuery 是继 prototype 之后又一个优秀的 Javascript 框架.其宗旨是—写更少的代码,做更多的事情.它是轻量级的 js 库(压缩后只有21k) ,这是其它的 js 库所不及的, ...
- IP地址规划和设计方法
IP地址规划和设计方法 无类域间路由技术需要在提高 IP 地址利用率和减少主干路由器负荷两个方面取得平衡 网络地址转换 NAT 最主要的应用是专用网,虚拟专用网,以及 ISP 为拨号用户 提供的服务 ...
- [转]SQL2005后的ROW_NUMBER()函数的应用
SQL Server 2005后之后,引入了row_number()函数,row_number()函数的分组排序功能使这种操作变得非常简单 分组取TOP数据是T-SQL中的常用查询, 如学生信息管理系 ...