Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define przek 0
- #define led_wew 2
- bool sendValue(const char* tag, String value);
- 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() {
- sendValue(pin7, String(t_on));
- pin7_lastValue = t_on;
- sendValue(pin8, String(t_off));
- pin8_lastValue = t_off;
- }
- int on_off = 0; // stan włącznika głównego
- int on_off_t = 0; // stan włącznika regulacji czasu
- void pin1_rec(String value_Text) {
- V1_Value = value_Text.toInt();
- 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);
- sendValue(pin6, String(stan_przek));
- pin6_lastValue = stan_przek;
- wys_t();
- speed_led();
- }
- int t_on_mem = 10;
- int t_off_mem = 10;
- void pin2_rec(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;
- sendValue(pin6, String(stan_przek));
- pin6_lastValue = stan_przek;
- wys_t();
- }
- void pin3_rec(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 pin4_rec(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);
- }
- int a = 0;
- int b = 0;
- void LED_timer() {
- a = !a;
- digitalWrite(led_wew, a);
- sendValue(pin0, String(b)); //led in virtuino
- pin0_lastValue = b;
- 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
Advertisement