/*
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. delphi c++builder JSON 生成与解析 例子

    json,System.JSON,REST.JSON JSON有两种数据结构,对象和数组. 对象在js中表示为“{}”括起来的内容,数据结构为 {key:value,key:value,...} 数组 ...

  2. UI5-文档-4.30-Debugging Tools

    虽然我们在前面的步骤中添加了一个基本的测试覆盖率,但是我们似乎不小心破坏了我们的应用程序,因为它不再显示价格到我们的发票上.我们需要调试这个问题,并在有人发现之前修复它. 幸运的是,SAPUI5提供了 ...

  3. jdk5新特性

    前两天看到jdk10试用版都出来了,才发现自己连1.8都没用过,对不同版本的jdk的新特性也不是太了解,所以想还是百度一下看看人家怎么说然后自己记录总结一下,其中jdk1.8的新特性可以到edu.51 ...

  4. shell中的条件判断以及与python中的对比

    shell中比如比较字符串.判断文件是否存在及是否可读等,通常用"[]"来表示条件测试. 注意:这里的空格很重要.要确保方括号的空格. if ....; then          ...

  5. sql语句执行的时间

    统计mysql里每条SQL语句执行的时间 收藏 CrazyHarry 发表于 2年前 阅读 3785 收藏 8 点赞 3 评论 3 Google.Github 双重认证前端课程,独家硅谷内容,每周直播 ...

  6. Ansible 管理MySQL主从复制

    mysql_replication - 管理MySQL复制 1.3版新功能 概要 要求(在执行模块的主机上) 选项 例子 笔记 状态 支持 概要 管理MySQL服务器复制,从属,主状态获取和更改主控主 ...

  7. Retrofit2+Rxjava2 okhttp RxBus 使用记录

    学习 博客 http://blog.csdn.net/r17171709/article/details/51149350 @Query 后面跟要添加的字段 @Path 连接url里面{userId} ...

  8. Java工具类_模拟HTTP POST请求

    import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.InputStream; i ...

  9. 二叉树的创建、遍历(递归和非递归实现)、交换左右子数、求高度(c++实现)

    要求:以左右孩子表示法实现链式方式存储的二叉树(lson—rson),以菜单方式设计并完成功能任务:建立并存储树.输出前序遍历结果.输出中序遍历结果.输出后序遍历结果.交换左右子树.统计高度,其中对于 ...

  10. 支付宝SDK ios快捷支付

    配置PartnerConfig.h的参数 //合作身份者id,以2088开头的16位纯数字 #define PartnerID @"" //收款支付宝账号 #define Sell ...