Archive for the ‘arduino’ Category

Arduino. Капельный полив растений.

Posted: 13th Август 2015 by shmyak in arduino

#include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,20,4); #define relay 13 #define MAX_FLOWTIME 180 // seconds #define MIN_FLOWTIME 30 // seconds #define MAX 1022 #define MIN 5 int volumePin = A0; long duration; long interval = 3000; long oldDuration; void setup() { Serial.begin(9600); pinMode(relay, OUTPUT); lcd.init(); lcd.backlight(); } void water() { static bool state; static unsigned long […]

Таймер для ардуины

Posted: 13th Август 2015 by shmyak in arduino

#define relay 13 long duration = 1000; long interval = 3000; void setup() { Serial.begin(9600); pinMode(relay, OUTPUT); } void loop() { static bool state; static unsigned long time; if((millis() — time) > (state ? duration : interval)) { state = !state; digitalWrite(relay, state); time = millis(); } }