手势
来源:互联网 发布:云购cms演示 编辑:程序博客网 时间:2024/04/24 08:16
/* DHCP-based IP printer This sketch uses the DHCP extensions to the Ethernet library to get an IP address via DHCP and print the address obtained. using an Arduino Wiznet Ethernet shield. Circuit: * Ethernet shield attached to pins 10, 11, 12, 13 created 12 April 2011 by Tom Igoe */#include <SPI.h>#include <Ethernet.h>// include the library code:#include <LiquidCrystal.h>#include <Wire.h>////define variables//int valread;int valread1;int temp=0;int temp1=0;String res="N" ; String flag ; String flag1; EthernetClient client; byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress serverIP(172,25,60,127); // IP Adress to our Server int serverPort=18000;void setup() { Serial.begin(9600); pinMode(7, INPUT); pinMode(6, INPUT); if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: for(;;) ; } Serial.print("My IP address: "); for (byte thisByte = 0; thisByte < 4; thisByte++) { // print the value of each byte of the IP address: Serial.print(Ethernet.localIP()[thisByte], DEC); Serial.print("."); } Serial.println();}void loop() { valread1=digitalRead(6); valread=digitalRead(7);temp=valread; // Serial.println(valread1);if( valread1==0){ // Serial.println("left"); flag1 ="Y"; if(flag =="Y"){ // Serial.println("RIGHT-left"); res="RIGHT-left"; flag =="N"; }} if( valread==0){ //Serial.println("right"); flag ="Y"; if(flag1 =="Y"){ //Serial.println("left-RIGHT"); res="left-RIGHT"; flag1 ="N"; } }if(valread==1&&valread1==1&&res!="N"){ Serial.println(res); if(res=="left-RIGHT"){ if (client.connect(serverIP, serverPort)) { Serial.println("connected");//report it to the Serial String msg="right;";//Message to be sent Serial.println("sending Message:"+msg);//log to serial client.println(msg);//send the message } } if(res=="RIGHT-left"){ if (client.connect(serverIP, serverPort)) { Serial.println("connected");//report it to the Serial String msg="left;";//Message to be sent Serial.println("sending Message:"+msg);//log to serial client.println(msg);//send the message } } res="N"; client.stop();} delay(10); // Serial.println(valread);}
0 0
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- 手势
- Open Inventor中将一个实体任意剖切 并显示切面
- 《语义网基础教程》学习笔记(一)
- Microsoft Interview
- C++输入/输出流类库
- Android高手进阶 AIDL
- 手势
- hdu 4901 The Romantic Hero(计数dp)2014多校训练第4场1005
- charindex
- c++ 1对多关系类,原创注明元元,否则会打击原创者的信心啊
- poj 1951 Extra Krunch
- [leetcode] 3Sum
- ActionScript3游戏中的图像编程(连载十九)
- shiro学习过程总结
- Android中jar包与source-jar的关联