- Tue Nov 24, 2015 7:10 pm
#34928
Hello everyone. I'm searching for a LUA script that makes the ESP recieve a value from a SW-420 vibration sensor (it's digital, so there's no problem) and send the value to a sever or client. I did something similar on an Arduino UNO, and here's my Arduino code so you can have a reference:
Code: Select all#include <SoftwareSerial.h>
int ledPin = 13;
int EP = 9;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(EP, INPUT);
Serial.begin(9600);
}
void loop() {
long medida = TP_init();
delay(50);
if(medida > 1000)
{
Serial.println(medida);
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
}
long TP_init()
{
delay(10);
long medida = pulseIn(EP, HIGH);
return medida;
}