Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Czujnik v2.0 by Paweł Rogala
- Nazwa modułu Bluetooth: "DUDA1"
- Hasło do parowania: "6969" */
- #define czujnikRuchu A0
- unsigned long currentMillis = 0;
- unsigned long prevMillis = 0;
- int interval = 10000; //wartość zaniżona na potrzeby testów, potem będzie 10 minut żeby oszczędzać energię
- int stanCzujnika = 0;
- void setup() {
- pinMode(czujnikRuchu, INPUT);
- Serial.begin(9600);
- }
- void loop() {
- stanCzujnika = analogRead(czujnikRuchu);
- if (stanCzujnika > 400) {
- sendAlarmData();
- }
- prevMillis = currentMillis;
- currentMillis = millis();
- if (currentMillis - prevMillis >= interval) {
- sendActivity();
- }
- }
- void sendAlarmData() {
- for(int i = 0; i <10; i++) {
- Serial.print("ALARM");
- delay(1000);
- }
- }
- void sendActivity() {
- Serial.print("ACTIVE");
- }
Advertisement
Add Comment
Please, Sign In to add comment