Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Timers.h> // my favorite timer
- Timers <4> akcja; // 4 wątki
- void setup() {
- Serial.begin(9600,SERIAL_8N1);
- Serial1.begin(9600,SERIAL_8N1);
- Serial1.setDebugOutput(true);
- // pinMode(LED_BUILTIN, OUTPUT);
- Serial.println("test started");
- Serial1.println("xxxxxxx");
- akcja.attach(0, 3000, blinkled);
- }
- bool wsk2 = 0;
- bool wsk1 = 0;
- void blinkled() {
- Serial.print("-");
- wsk2 = !wsk2;
- if (wsk2)wsk1 = !wsk1;
- // digitalWrite(LED_BUILTIN, wsk2);
- // Serial.println("abcd");
- if (wsk1 == 0) {
- if (wsk2 == 0) {
- Serial1.write(0xBB);
- Serial1.write(0xCC);
- Serial1.write(0x00);
- Serial1.write(0x00);
- Serial1.write(0x00);
- Serial1.write(0x00);
- Serial1.write(0xB4);
- // Serial.println("1");
- } else {
- Serial1.write(0xBB);
- Serial1.write(0xCC);
- Serial1.write(0x00);
- Serial1.write(0x01);
- Serial1.write(0x00);
- Serial1.write(0x00);
- Serial1.write(0xDF);
- // Serial.println("2");
- }
- }
- if (wsk1 == 1) {
- if (wsk2 == 0) {
- Serial1.write(0xBB);
- Serial1.write(0xCC);
- Serial1.write(0x01);
- Serial1.write(0x00);
- Serial1.write(0x00);
- Serial1.write(0x00);
- Serial1.write(0x88);
- // Serial.println("3");
- } else {
- Serial1.write(0xBB);
- Serial1.write(0xCC);
- Serial1.write(0x01);
- Serial1.write(0x01);
- Serial1.write(0x00);
- Serial1.write(0x00);
- Serial1.write(0x89);
- // Serial.println("4");
- }
- }
- }
- void half_bridge() {
- while (Serial.available() > 0) {
- Serial.write(Serial.read());
- yield();
- }
- }
- void loop() {
- akcja.process(); //
- half_bridge();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement