auto-awning-close/_no-idea-what-it-is/controller/controller.ino

123 lines
2.3 KiB
Arduino
Raw Normal View History

2021-05-03 17:07:23 +02:00
#include <VirtualWire.h>
int led = 2;
int btnA = 4;
int btnB = 5;
int btnC = 6;
int btnD = 7;
int transmitter = 8;
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(btnA, INPUT);
pinMode(btnB, INPUT);
pinMode(btnC, INPUT);
pinMode(btnD, INPUT);
// vysilac
// nastavení typu bezdrátové komunikace
vw_set_ptt_inverted(true);
// nastavení čísla datového pinu pro vysílač
vw_set_tx_pin(transmitter);
// nastavení rychlosti přenosu v bitech za sekundu
vw_setup(1000);
}
2021-05-03 20:40:39 +02:00
/* const char whichButtonWasPressed()
2021-05-03 17:07:23 +02:00
{
Serial.write("\n\nreturn false\n\n");
return "";
2021-05-03 20:40:39 +02:00
} */
2021-05-03 17:07:23 +02:00
2021-05-03 20:40:39 +02:00
/* void sendMsg(inputMsg)
2021-05-03 17:07:23 +02:00
{
2021-05-03 20:40:39 +02:00
Serial.write("input");
// Serial.write(input)
Serial.write("\n odesilani...\n");
switch (inputMsg)
{
case 'A':
vw_send((uint8_t *)"1", strlen("1"));
break;
case 'B':
vw_send((uint8_t *)"2", strlen("2"));
break;
case 'C':
vw_send((uint8_t *)"3", strlen("3"));
break;
case 'D':
vw_send((uint8_t *)"4", strlen("4"));
break;
default:
vw_send((uint8_t *)"0", strlen("0"));
}
2021-05-03 17:07:23 +02:00
vw_wait_tx();
2021-05-03 20:40:39 +02:00
digitalWrite(13, false);
delay(900);
} */
2021-05-03 17:07:23 +02:00
void loop()
{
2021-05-03 20:40:39 +02:00
String pressedBtn = "N";
2021-05-03 17:07:23 +02:00
if (digitalRead(btnA) == HIGH)
{
Serial.write("btna");
2021-05-03 20:40:39 +02:00
pressedBtn = "A";
Serial.write("\n odesilani...\n");
vw_send((uint8_t *)"1", strlen("1"));
vw_wait_tx();
digitalWrite(13, false);
delay(900);
2021-05-03 17:07:23 +02:00
}
2021-05-03 20:40:39 +02:00
2021-05-03 17:07:23 +02:00
if (digitalRead(btnB) == HIGH)
{
Serial.write("btnb");
2021-05-03 20:40:39 +02:00
pressedBtn = "B";
Serial.write("\n odesilani...\n");
vw_send((uint8_t *)"2", strlen("2"));
vw_wait_tx();
digitalWrite(13, false);
delay(900);
2021-05-03 17:07:23 +02:00
}
2021-05-03 20:40:39 +02:00
2021-05-03 17:07:23 +02:00
if (digitalRead(btnC) == HIGH)
{
Serial.write("btnc");
2021-05-03 20:40:39 +02:00
pressedBtn = "C";
Serial.write("\n odesilani...\n");
vw_send((uint8_t *)"3", strlen("3"));
2021-05-03 17:07:23 +02:00
vw_wait_tx();
digitalWrite(13, false);
delay(900);
}
2021-05-03 20:40:39 +02:00
2021-05-03 17:07:23 +02:00
if (digitalRead(btnD) == HIGH)
{
Serial.write("btnd");
2021-05-03 20:40:39 +02:00
pressedBtn = "D";
Serial.write("\n odesilani...\n");
vw_send((uint8_t *)"4", strlen("4"));
vw_wait_tx();
digitalWrite(13, false);
delay(900);
2021-05-03 17:07:23 +02:00
}
2021-05-03 20:40:39 +02:00
}
/* vw_send((uint8_t *)"1", strlen("1"));
vw_wait_tx();
digitalWrite(13, false);
delay(900); */