Demo entry 6850748

whatever

   

Submitted by anonymous on Jul 11, 2019 at 09:47
Language: C++. Code size: 1.8 kB.

#include <stdio.h>  
  
int pushButton1 = 5;  
int pushButton2 = 6;  
int pushButton3 = 7;  
int pushButton4 = 8;  
  
void setup() {  
  // initialize serial communication at 9600 bits per second:  
  Serial.begin(9600);  
  // make the pushbutton's pin an input:  
  pinMode(pushButton, INPUT);  
  Serial.println("AT+TMODE=HTPC");  
  delay(2000);  
  Serial.println("AT+HTPTP=GET");  
  delay(2000);  
  Serial.println("AT+HTPSV=10.10.100.1,80");  
  delay(2000);  
  Serial.println("AT+HTPURL=/newdata.php[3F]");  
  delay(2000);  
  Serial.println("AT+HTPTO=10");  
  delay(2000);  
  Serial.println("AT+HTPHD=Accept:text/html[0D][0A]Accept-Language:zh-CN[0D][0A]User-Agent: Mozilla/5.0[0D][0A]Connection:Keep-Alive[0D][0A]");  
  delay(2000);  
  Serial.println("AT+HTPFT=ON");  
  delay(2000);  
}  
  
void loop() {  
  int bs1 = digitalRead(pushButton1);//bs是buttonstate,按钮状态  
  int bs2 = digitalRead(pushButton2);  
  int bs3 = digitalRead(pushButton3);  
  int bs4 = digitalRead(pushButton4);  
  int s1 = 0;int s2 = 0;int s3 = 0;int s4 = 0;//s = seat  
  
//轻触几号按键,则代表有几个座位被占用,而且按照1-4的顺序占用座位  
  
  while(bs1==1&&bs2==0&&bs3==0&&bs4==0){  
    s1 = 1;s2 = 0;s3 = 0;s4 = 0;  
  }  
  while(bs1==0&&bs2==1&&bs3==0&&bs4==0){  
    s1 = 1;s2 = 1;s3 = 0;s4 = 0;  
  }  
  while(bs1==0&&bs2==0&&bs3==1&&bs4==0){  
    s1 = 1;s2 = 1;s3 = 1;s4 = 0;  
  }  
  while(bs1==0&&bs2==0&&bs3==0&&bs4==1){  
    s1 = 1;s2 = 1;s3 = 1;s4 = 1;  
  }  
    
  Serial.print("bus_id=1&seat1=");  
  Serial.print(str(s1));  
  Serial.print("&seat2=");  
  Serial.print(str(s2));  
  Serial.print("&seat3=");  
  Serial.print(str(s3));  
  Serial.print("&seat4=");  
  Serial.println(str(s4));  
  delay(3000);  
}  

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).