Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define przek 0
- #define led_wew 2
- int V1_Value = 0;
- int V2_Value = 0;
- int V3_Value = 0;
- int V4_Value = 0;
- int t_on = 10;
- int t_off = 10;
- int stan_przek = 1; //0 włączony 1 wyłączony 2 regulowany czas załączenia
- void speed_led() {
- if (stan_przek == 1) akcja.updateInterval(0, 2000);
- if (stan_przek == 0) akcja.updateInterval(0, 1000);
- if (stan_przek == 2) akcja.updateInterval(0, 500);
- }
- void wys_t() {
- V7 = String(t_on);
- V8 = String(t_off);
- }
- int on_off = 0; // stan włącznika głównego
- int on_off_t = 0; // stan włącznika regulacji czasu
- void Read_V1(String value_Text) {
- V1_Value = value_Text.toInt();
- // Serial.println("V1=" + value_Text);
- if (V1_Value) on_off = 1;
- else on_off = 0;
- if (on_off) {
- if (on_off_t) stan_przek = 2;
- else stan_przek = 0;
- } else stan_przek = 1;
- digitalWrite(przek, V1_Value);
- V6 = String(stan_przek);
- wys_t();
- speed_led();
- }
- int t_on_mem = 10;
- int t_off_mem = 10;
- void Read_V2(String value_Text) {
- V2_Value = value_Text.toInt();
- // Serial.println("V2=" + value_Text);
- on_off_t = V2_Value;
- if (on_off_t) t_on = t_on_mem;
- // else t_on = 0;
- if (on_off_t) t_off = t_off_mem;
- // else t_off = 0;
- if (on_off_t)
- ;
- else stan_przek = !on_off;
- V6 = String(stan_przek);
- wys_t();
- }
- void Read_V3(String value_Text) {
- V3_Value = value_Text.toInt();
- t_on_mem = V3_Value;
- t_on = t_on_mem;
- wys_t();
- //Serial.println("V3=" + value_Text);
- }
- void Read_V4(String value_Text) {
- V4_Value = value_Text.toInt();
- t_off_mem = V4_Value;
- t_off = t_off_mem;
- wys_t();
- // Serial.println("V4=" + value_Text);
- }
- void p_setup() {
- pinMode(led_wew, OUTPUT); //LED na module
- digitalWrite(led_wew, HIGH);
- pinMode(przek, OUTPUT); //pin przekaźnika
- digitalWrite(przek, HIGH);
- }
- // This is the value that you want to send to virtuino APP
- int a = 0;
- void LED_timer() {
- a = !a;
- digitalWrite(led_wew, a);
- }
- int b = 0;
- void vLED_timer() {
- V0 = String(b); //LED in virtuino
- b = !b;
- }
- void czas_timer() {
- if (stan_przek > 1) {
- if (stan_przek == 2) {
- t_on = t_on - 1;
- if (t_on < 1) {
- t_off = t_off_mem + 1;
- digitalWrite(przek, HIGH);
- stan_przek = 3;
- }
- }
- if (stan_przek == 3) {
- t_off = t_off - 1;
- if (t_off < 1) {
- t_on = t_on_mem;
- digitalWrite(przek, LOW);
- stan_przek = 2;
- }
- }
- }
- wys_t();
- }
- void program_grzalka() {
- //my program tu akurat nic nie ma
- }
Advertisement
Add Comment
Please, Sign In to add comment