Init commit with many years of arduino sketches and projects. I dont know if the esp8266 includes much, but there are also libraries. I hope they dont have crazy automatic versioning through the Arduino IDE.

This commit is contained in:
2019-05-30 23:41:53 +02:00
parent 2d047634f2
commit 6c84b31f2c
1480 changed files with 198581 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
int ledPin = 13;
int inputPins[] = {2, 4};
bool pirState[] = {0, 0};
int val[] = {0, 0};
void setup() {
delay(1500);
pinMode(ledPin, OUTPUT);
pinMode(inputPins[0], INPUT);
pinMode(inputPins[1], INPUT);
Serial.begin(9600);
}
void loop()
{
val[0] = digitalRead(inputPins[0]);
val[1] = digitalRead(inputPins[1]);
if (val[0] == 1)
{
if (checkState(1) == 1) {
turnOn();
}
}
else if (val[1] == 1)
{
if (checkState(0) == 1) {
turnOn();
}
}
Serial.println(val[0]);
Serial.println(val[1]);
Serial.println();
delay(100);
}
void turnOn()
{
digitalWrite(ledPin, HIGH);
delay(3000);
digitalWrite(ledPin, LOW);
}
int checkState(int sensorID)
{
int changeState = 0;
for (int i = 0; i < 10; i++)
{
if (digitalRead(inputPins[sensorID]) == 1) {
changeState = 1;
}
delay(100);
}
return changeState;
}