Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SoftwareSerial.h>
  2. int on = 0;
  3. int done = 1;
  4.  
  5. SoftwareSerial mySerial(3, 2); //SIM800L Tx & Rx is connected to Arduino #3 & #2
  6.  
  7. #include <FastLED.h>
  8.  
  9. #define NUM_LEDS 12
  10. #define DATA_PIN 6
  11. CRGB leds[NUM_LEDS];
  12.  
  13. int ledState = 0;
  14. int buttonState;
  15. int lastButtonState = LOW;
  16.  
  17. unsigned long paskutinislaikas = 0;
  18. unsigned long delayisjungti = 2000;
  19.  
  20. void setup()
  21. {
  22.   Serial.begin(9600);
  23.  
  24.   mySerial.begin(9600);
  25.   pinMode(5, INPUT);
  26.   pinMode(4, OUTPUT);
  27.   pinMode(7, OUTPUT);
  28.   Serial.println("Initializing...");
  29.   FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  30.  
  31.   delay(1000);
  32.  
  33.  
  34. }
  35.  
  36. void loop()
  37. {
  38.   if (digitalRead(5) == 0) {
  39.     paskutinislaikas = millis();
  40.   }
  41.   if ((millis() - paskutinislaikas) > delayisjungti) {
  42.     ledState = 0;
  43.     done = 0;
  44.   } else {
  45.     ledState = 1;
  46.     digitalWrite(4, LOW);
  47.   }
  48.  
  49.  
  50.   if (ledState == 1 && done == 0) {
  51.     digitalWrite(7, HIGH);
  52.     mySerial.println("AT");
  53.     delay(350);
  54.     mySerial.println("AT+CMGF=1"); //TEXT mode
  55.     delay(350);
  56.     mySerial.println("AT+CMGS=\"+37060904090\"");
  57.     delay(350);
  58.     mySerial.print("test");
  59.     delay(350);
  60.     mySerial.write(26); //šitas yra būtinas išsiųsti sms
  61.  
  62.     for (int i = 11; i >= 0; i--) {
  63.       leds[i] = CRGB(255, 40, 0);
  64.       FastLED.show();
  65.       delay(60);
  66.     }
  67.     delay(10);
  68.     for (int i = 11; i >= 0; i--) {
  69.       leds[i] = CRGB::Black;
  70.       FastLED.show();
  71.       delay(65);
  72.     }
  73.     delay(10);
  74.  
  75.     digitalWrite(7, LOW);
  76.  
  77.     done = 1;
  78.  
  79.   }
  80.  
  81.   if (ledState == 1 && done == 1) {
  82.  
  83.     for (int i = 11; i >= 0; i--) {
  84.       leds[i] = CRGB(255, 40, 0);
  85.       FastLED.show();
  86.       delay(60);
  87.     }
  88.     delay(10);
  89.     for (int i = 11; i >= 0; i--) {
  90.       leds[i] = CRGB::Black;
  91.       FastLED.show();
  92.       delay(65);
  93.     }
  94.  
  95.   } else {
  96.  
  97.     digitalWrite(4, HIGH);
  98.     for (int i = 11; i >= 0; i--) {
  99.       leds[i] = CRGB::Black;
  100.       FastLED.show();
  101.     }
  102.  
  103.   }
  104.  
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement