Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void pin_to_app ();
- #define led_wew 2
- void setup_program()
- {
- pinMode(led_wew, OUTPUT);
- }
- void loop_program()
- {
- pin_to_app ();
- }
- //================ app -----> esp
- void pin0_rec(String value) //LED in ESP
- {
- int v = value.toInt();
- if (v == 1) digitalWrite(led_wew, HIGH); else digitalWrite(led_wew, LOW);
- }
- // //---Example 1: How to send a data to Virtuino app periodically
- int wsk_led = 0;
- void vLED_timer() // esp -----> app every 2100 ms
- {
- wsk_led = !wsk_led;
- sendValue(pin12, String(wsk_led)); //esp ----> app
- }
- void test() { // esp -----> app every 3005 ms
- int sensor = random(50);
- sendValue(pin10, String(sensor));
- }
- void pin_to_app () {
- //---Example 2: How to send a Digital Input state to Virtuino app every time it changes
- int pin11_val = 10; // read the new state
- if (pin11_lastValue != pin11_val) { // compare with the previous input state
- sendValue(pin11, String(pin11_val)); // send the new state esp ----> app
- pin11_lastValue = pin11_val; // copy the new state to variable pin0_lastValue
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement