Skip to content

Commit

Permalink
Correción de datos
Browse files Browse the repository at this point in the history
  • Loading branch information
sabas1080 committed Aug 15, 2015
1 parent bef5f3d commit e76285d
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions hardware-counter/hardware-counter.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Autores:
* Andres Sabas <[email protected]>
* Andres Sabas <[email protected]>
* Iddar Olivares <[email protected]>
* Creado: Julio 2015
* Contador de personas con
Expand All @@ -15,10 +15,11 @@
WebSocketsClient webSocket;


const char* ssid = "INFINITUM38FA71";
const char* password = "22B578FD01";
const char* ssid = "Wifi Name";
const char* password = "Wifi password";

#define USE_SERIAL Serial
int a=0;

void webSocketEvent(WStype_t type, uint8_t * payload, size_t lenght) {

Expand All @@ -29,6 +30,19 @@ void webSocketEvent(WStype_t type, uint8_t * payload, size_t lenght) {
case WStype_CONNECTED:
USE_SERIAL.printf("[WSc] Connected to url: %s\n", payload);
break;
// echo data back to Server


if(a==1){
webSocket.sendTXT("in", 2);
}
break;
if(a==2){
webSocket.sendTXT("out", 3);
a=0;
break;
}

}

}
Expand All @@ -37,11 +51,8 @@ void webSocketEvent(WStype_t type, uint8_t * payload, size_t lenght) {
void setup() {
pinMode(4,INPUT);
pinMode(13,INPUT);
pinMode(0,INPUT);
pinMode(5,OUTPUT);
pinMode(12,OUTPUT);

attachInterrupt(0, inPeople, RISING);
attachInterrupt(4, inPeople, RISING);
attachInterrupt(13, outPeople, RISING);

Expand All @@ -62,7 +73,7 @@ void setup() {
delay(100);
}

webSocket.begin("192.168.1.65", 3000);
webSocket.begin("192.168.0.43", 8080);
webSocket.onEvent(webSocketEvent);
}

Expand All @@ -71,9 +82,19 @@ void loop() {
}

void inPeople() {
webSocket.sendTXT("in", 2);
while(digitalRead(13))
{
detachInterrupt(4);
}
a=1;
}

void outPeople() {
webSocket.sendTXT("out", 3);
//webSocket.sendTXT("out", 3);

while(digitalRead(4))
{
detachInterrupt(13);
}
a=2;
}

0 comments on commit e76285d

Please sign in to comment.