/*
Web client This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield. Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13 created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe, based on work by Adrian McEwen */
#include <SPI.h>
#include <Ethernet.h>
#include <LiquidCrystal.h> #define ResetPIN 7 // 初始化引脚
LiquidCrystal lcd(, , , , , ); // Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAA, 0xCE, 0xEA, 0xFF, 0xE1 };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
char server[] = "192.168.9.6"; // name address for Google (using DNS)
String clientPwd="-1"; // Set the static IP address to use if the DHCP fails to assign
IPAddress ip(,,,);
IPAddress gateway(,,,);
IPAddress dns_server(,,,);
IPAddress subnet(,,,);
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client; int errCount=; void setup() { //LCD
// 设置行列值
lcd.begin(, ); pinMode(ResetPIN,OUTPUT);
digitalWrite(ResetPIN,LOW); // Open serial communications and wait for port to open:
Serial.begin();
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
// give the Ethernet shield a second to initialize:
if (Ethernet.begin(mac) == ) {
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, ip,dns_server,gateway,subnet);
} delay();
Serial.println("Ready");
} void loop()
{ Serial.println(clientPwd);
// 打印字符串
lcd.setCursor(,);
lcd.print(clientPwd); httpRequest();
delay(); } //================Http Request Code========================
void httpRequest(){
// if you get a connection, report back via serial: if(!client.connected()){
Serial.println("disconnecting.");
client.stop();
if (client.connect(server, )) {
Serial.println("connected");
}else{
// kf you didn't get a connection to the server:
Serial.println("connection failed");
errCount++;
if(errCount>=){
digitalWrite(ResetPIN,HIGH);
delay();
}
}
} else{ // Make a HTTP request:
client.println("GET /main.ashx?m=c&mil=" + String(millis()) + "&cpwd="+clientPwd+"&rf=0" +" HTTP/1.1");
client.println("Host:" +String(server));
//client.println("Connection: close"); client.println();
delay();
String reply="";
// if there are incoming bytes available
// from the server, read them and print them:
while (client.available()) {
char c = client.read();
reply+=c; }
//Serial.print(reply);
int index=reply.indexOf("\"Model\":\"8888");
if(index>=){
index=index+;
clientPwd= reply.substring(index,index+);
Serial.println("Changed:" + clientPwd); } errCount=;
//wdt_reset();
} }
//================End Http Request Code===============

arduino网卡扩展板,会使用 2,10,11,12,13 i/o口,所以要调整lcd使用的接口

人体感应器信号输出连S9013三极管(来控制lcd背景灯的亮与灭(使用K编号的脚)

/*
Web client This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield. Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13 created 18 Dec 2009
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe, based on work by Adrian McEwen */
#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <avr/wdt.h> #define ResetPIN 7
#define HasManPIN 8
#define RebootPIN 6 // Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAA, 0xCE, 0x3A, 0x6F, 0xE1 };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
char server[] = "192.168.9.6"; // name address for Google (using DNS)
String clientPwd="-1";
int hasMan=;
LiquidCrystal_I2C lcd(0x27,,); // Set the static IP address to use if the DHCP fails to assign
IPAddress ip(,,,);
IPAddress gateway(,,,);
IPAddress dns_server(,,,);
IPAddress subnet(,,,);
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client; int errCount=;
unsigned long lastRequest=; void setup() { pinMode(HasManPIN,INPUT);
pinMode(ResetPIN,OUTPUT);
pinMode(RebootPIN,OUTPUT); digitalWrite(ResetPIN,LOW);
digitalWrite(RebootPIN,LOW); // Open serial communications and wait for port to open:
Serial.begin();
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
// give the Ethernet shield a second to initialize:
if (Ethernet.begin(mac) == ) {
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, ip,dns_server,gateway,subnet);
} lcd.init();
lcd.backlight();
lcd.print("-1");
delay();
Serial.println("Ready");
lastRequest=millis(); wdt_enable(WDTO_8S);
} void loop()
{
//digitalWrite(RebootPIN,LOW); if((millis()-lastRequest)>=){
Serial.println("reboot");
digitalWrite(ResetPIN,HIGH);
delay();
}
Serial.println("lcd...");
Serial.println(clientPwd);
// 打印字符串
lcd.setCursor(,);
lcd.print(clientPwd); //digitalWrite(RebootPIN,HIGH); hasMan=digitalRead(HasManPIN);
Serial.println(hasMan);
if(hasMan==){
lcd.backlight();
}else{
lcd.noBacklight();
} if( (millis() - lastRequest) >=)
{
httpRequest();
lastRequest=millis();
} delay();
Serial.println("lcd over!");
//
wdt_reset(); } //================Http Request Code========================
void httpRequest(){
// if you get a connection, report back via serial: if(!client.connected()){
Serial.println("disconnecting.");
client.stop();
if (client.connect(server, )) {
Serial.println("connected");
}else{
// kf you didn't get a connection to the server:
Serial.println("connection failed");
errCount++;
if(errCount>=){
digitalWrite(ResetPIN,HIGH);
delay();
}
}
} else{ // Make a HTTP request:
client.println("GET /main.ashx?m=c&mil=" + String(millis()) + "&cpwd="+clientPwd+"&rf="+String(hasMan) +" HTTP/1.1");
client.println("Host:" +String(server));
//client.println("Connection: close"); client.println();
delay();
String reply="";
// if there are incoming bytes available
// from the server, read them and print them:
while (client.available()) {
char c = client.read();
reply+=c; }
//Serial.print(reply);
int index=reply.indexOf("\"Model\":\"8888");
if(index>=){
index=index+;
clientPwd= reply.substring(index,index+);
Serial.println("Changed:" + clientPwd); } errCount=;
//wdt_reset();
} }
//================End Http Request Code===============

人体感应模块控制LCD1602背景灯是否开启的更多相关文章

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

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

  2. arduino 蓝牙控制RGB LED灯

    /* 日期:2016.9.2 功能:arduino 蓝牙控制RGB LED灯 元件: 跳线公公头 * 8 rgbled, 220欧电阻 蓝牙模块 接线: 蓝牙模块VCC,GND分别接5V,GND;TX ...

  3. 使用按钮控制HTML5背景音乐开关

    <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <meta name ...

  4. 89C51单片机定时器控制的流水灯

    /***************************************************Copyright: 2014-02-11.version1.0File name: timer ...

  5. K1 K2作为中断源控制红色LED灯,实现任意键按一下LED灯亮或者灭

    #include "stm32f10x.h" // 相当于51单片机中的 #include <reg51.h> #include "stm32f10x_gpi ...

  6. 用selenium 模块控制浏览器

    11.8 用selenium 模块控制浏览器selenium 模块让Python 直接控制浏览器,实际点击链接,填写登录信息,几乎就像是有一个人类用户在与页面交互.与Requests 和Beautif ...

  7. selenium模块控制浏览器

    利用selenium模块控制浏览器 导入selenium模块:from selenium import webdriver browserFirefox = webdriver.Firefox()#打 ...

  8. 【MM系列】SAP MM模块-控制采购订单中某些项目的输出显示

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP MM模块-控制采购订单中某些 ...

  9. Arduino 各种模块篇 蓝牙模块 手机蓝牙控制Arduino LED灯

    解决方案. 条件: 1.手机android 商店下载 blueTerm 2.向arduino中载入如下代码: char val; ; void setup() { Serial.begin(); pi ...

随机推荐

  1. Spring Boot实践——Mybatis分页插件PageHelper的使用

    出自:https://blog.csdn.net/csdn_huzeliang/article/details/79350425 在springboot中使用PageHelper插件有两种较为相似的方 ...

  2. Haskell语言学习笔记(59)Bitraversable

    Bitraversable class (Bifunctor t, Bifoldable t) => Bitraversable t where bitraverse :: Applicativ ...

  3. 迷你MVVM框架 avalonjs 学习教程11、循环操作

    avalon是通过ms-repeat实现对一组数据的批量输出.这一组数据可以是一个数组,也可以是一个哈希(或叫对象).我们先从数组说起吧. 第二节就说,凡是定义在VM中的数组,如果没有以$开头或者没放 ...

  4. keras各种优化方法总结 SGDmomentumnesterov

    http://blog.csdn.net/luo123n/article/details/48239963 前言 这里讨论的优化问题指的是,给定目标函数f(x),我们需要找到一组参数x,使得f(x)的 ...

  5. org.springframework.stereotype 注解

    org.springframework.stereotype 1.@controller 控制器(注入服务) 2.@service 服务(注入dao) 3.@repository dao(实现dao访 ...

  6. Extending Conductor

    后端 导体提供了可插拔的后端.目前的实现使用Dynomite. 每个后端需要实现4个接口: //Store for workflow and task definitions com.netflix. ...

  7. Process ProcessThread Thread

    Process ProcessThread: Process and ProcessThread objects have a ProcessorAffinity property of IntPtr ...

  8. 通过NBU还原数据库提示LINKING异常,无法恢复数据

    错误提示: 解决方法:

  9. ajax返回填充的数据不显示

    原因:样式与id引用了其他的css或者js,删除其他样式,改变id就可以了

  10. 第七章 二叉搜索树 (d3)AVL树:删除