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,57 @@
#include <Servo.h>
#include <NewPing.h>
#define Trigger_Pin 12
#define Echo_Pin 11
#define Max_Distance 200
// Green car - 10
// Yellow car - 9
// Red car - 8
// Green person - 7
// Red person - 6
// ECHO 11 & 12
NewPing sonar(Trigger_Pin, Echo_Pin, Max_Distance);
Servo gateServo;
int servoPos = 0;
int lightPinArray[] = {
10, 9, 9, 8, 7, 6, 6, 7, 9, 8, 9};
boolean lightStateArray[] = {
LOW, HIGH, LOW, HIGH, LOW, HIGH, LOW, HIGH, HIGH, LOW, LOW};
int lightDelayArray[] = {
1000, 0, 500, 0, 500, 0, 2000, 0, 500, 500, 0};
void setup()
{
for (int i = 0; i < 5; i++)
{
pinMode(i + 6, OUTPUT);
}
gateServo.attach(4);
}
void personDetected()
{
for(int i = 0; i < 12; i++)
{
delay(lightDelayArray[i]);
digitalWrite(lightPinArray[i], lightStateArray[i]);
}
void loop()
{
unsigned int uS = sonar.ping();
if ((uS /US_ROUNDTRIP_CM) < 5 && uS /US_ROUNDTRIP_CM > 1)
{
personDetected();
}
else
{
digitalWrite(7, HIGH);
digitalWrite(10, HIGH);
}
}

Binary file not shown.