remove duplicates

master
shark 6 years ago
parent e6832551b0
commit a404925725

@ -1,364 +0,0 @@
// include the library code:
#include <LiquidCrystal.h>
#include <Time.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
int a = 1, b = 5, c = 2, d = 5, e = 0, f = 4, g = 4, h = 1, i = 2, j = 7;
unsigned long timeset = 0;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const int trigPin = 9;
const int echoPin = 8;
long duration;
int distance = 0;
unsigned long wait;
time_t last = 0;
unsigned long lastlong = 0;
int prevphoto = 0;
int today = 0;
int oldday;
boolean check = false;
void setup() {
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
pinMode(10, OUTPUT); // pin that enables backlight
digitalWrite(10, HIGH);
setuptime();
}
void loop() {
}
void setuptime() {
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("Enter UNIX time");
lcd.setCursor(0, 0);
lcd.print(a);
while (digitalRead(7) == 0) {
if(digitalRead(6) == 1) {
a+=1;
if(a == 10) {
a = 0;
}
lcd.setCursor(0, 0);
lcd.print(a);
delay(200);
}
}
delay(250);
lcd.setCursor(1, 0);
lcd.print(b);
while (digitalRead(7) == 0) {
if(digitalRead(6) == 1) {
b+=1;
if(b == 10) {
b = 0;
}
lcd.setCursor(1, 0);
lcd.print(b);
delay(200);
}
}
delay(250);
lcd.setCursor(2, 0);
lcd.print(c);
while (digitalRead(7) == 0) {
if(digitalRead(6) == 1) {
c+=1;
if(c == 10) {
c = 0;
}
lcd.setCursor(2, 0);
lcd.print(c);
delay(200);
}
}
delay(250);
lcd.setCursor(3, 0);
lcd.print(d);
while (digitalRead(7) == 0) {
if(digitalRead(6) == 1) {
d+=1;
if(d == 10) {
d = 0;
}
lcd.setCursor(3, 0);
lcd.print(d);
delay(200);
}
}
delay(250);
lcd.setCursor(4, 0);
lcd.print(e);
while (digitalRead(7) == 0) {
if(digitalRead(6) == 1) {
e+=1;
if(e == 10) {
e = 0;
}
lcd.setCursor(4, 0);
lcd.print(e);
delay(200);
}
}
delay(250);
lcd.setCursor(5, 0);
lcd.print(f);
while (digitalRead(7) == 0) {
if(digitalRead(6) == 1) {
f+=1;
if(f == 10) {
f = 0;
}
lcd.setCursor(5, 0);
lcd.print(f);
delay(200);
}
}
delay(250);
lcd.setCursor(6, 0);
lcd.print(g);
while (digitalRead(7) == 0) {
if(digitalRead(6) == 1) {
g+=1;
if(g == 10) {
g = 0;
}
lcd.setCursor(6, 0);
lcd.print(g);
delay(200);
}
}
delay(250);
lcd.setCursor(7, 0);
lcd.print(h);
while (digitalRead(7) == 0) {
if(digitalRead(6) == 1) {
h+=1;
if(h == 10) {
h = 0;
}
lcd.setCursor(7, 0);
lcd.print(h);
delay(200);
}
}
delay(250);
lcd.setCursor(8, 0);
lcd.print(i);
while (digitalRead(7) == 0) {
if(digitalRead(6) == 1) {
i+=1;
if(i == 10) {
i = 0;
}
lcd.setCursor(8, 0);
lcd.print(i);
delay(200);
}
}
delay(250);
lcd.setCursor(9, 0);
lcd.print(j);
while (digitalRead(7) == 0) {
if(digitalRead(6) == 1) {
j+=1;
if(j == 10) {
j = 0;
}
lcd.setCursor(9, 0);
lcd.print(j);
delay(200);
}
} // on the next line, for f I have to divide by 10 and add a zero otherwise it gives a negative number for some reason
timeset = (1000000000 * a)+(100000000 * b)+(10000000 * c)+(1000000 * d)+(100000 * e)+(100000 * f / 10)+(1000 * g)+(100 * h)+(10 * i)+j;
unsigned long timesetcst = timeset - 18000; //convert to central time from utc
setTime(timesetcst);
delay(250);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(timeset);
lcd.setCursor(0, 1);
lcd.print("is this ok?");
while (digitalRead(7) == 0) {
if(digitalRead(6) == 1) {
delay(200);
setuptime();
}
}
delay(250);
unsigned long oldtime = 0;
unsigned long clockoffset = now();
check = false;
while(1 == 1) {
time_t t = now();
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration*0.034/2;
// Prints the distance on the Serial Monitor
//Serial.print("Distance: ");
//Serial.println(distance);
if(distance < 30 || analogRead(3) >= 100 || digitalRead(7) == 1 || digitalRead(6) == 1) {
digitalWrite(10, HIGH);
wait = now();
}
if(digitalRead(7) == 1) {
if(check == false){
check = true;
delay(100);
} else {
check = false;
delay(100);
}
}
if(digitalRead(6) == 1 && check == true) {
delay(200);
setuptime();
}
if(now() != oldtime) {
//if(check == false) {
//Serial.println(analogRead(3));
if(now()-1500 >= clockoffset) {
if(now()-15 >= wait && analogRead(3) < 100) {
digitalWrite(10, LOW); // just in case the arduino skips a second at the wrong time
}
if(day(t) != oldday) {
today = 0;
}
setTime(now() + 1);
clockoffset = now();
}
if(now()-15 >= wait && analogRead(3) < 100) {
digitalWrite(10, LOW);
}
if(day(t) != oldday) {
today = 0;
}
lcd.setCursor(0,0);
lcd.clear(); /*
lcd.print(hourFormat12(t));
lcd.print(":");
if(minute(t) < 10) {
lcd.print("0");
}
lcd.print(minute(t));
lcd.print(" ");
if(isAM(t) == true) {
lcd.print("AM");
}
else {
lcd.print("PM");
} */
if (analogRead(3) < 100 && prevphoto >=100) {
last = now();
lastlong = now();
today ++;
}
if(lastlong == 0) {
lcd.print("LF: ");
if (analogRead(3) > 100) {
if(now() > 1526169600 && now() < 1526274000) {
lcd.clear();
lcd.print("Happy Mother's");
lcd.setCursor(0, 1);
lcd.print("Day! :)");
} else {
lcd.print("Can is open");
}
} else {
lcd.print("never");
}
}
else {
lcd.print("LF: ");
if (analogRead(3) > 100) {
if(now() > 1526169600 && now() < 1526274000) {
lcd.clear();
lcd.print("Happy Mother's");
lcd.setCursor(0, 1);
lcd.print("Day! :)");
} else {
lcd.print("Can is open");
}
} else {
int hours = (int)(now() / 3600) - (int)(lastlong / 3600);
int minutes = (now() / 60) - (lastlong / 60) - hours * 60;
while(minutes < 0) {
minutes = minutes + 60;
hours --;
}
if(hours > 24) {
lcd.print("over 24 hours ago");
} else {
lcd.print(hours);
lcd.print(" hr ");
lcd.print(minutes);
lcd.print(" min");
}
}
if((now() < 1526169600 || now() > 1526274000) || analogRead(3) < 100) {
lcd.setCursor(0, 1);
lcd.print(" Today: ");
lcd.print(today);
lcd.print(" Meal");
if(today != 1) {
lcd.print("s");
}
}
}
//lcd.setCursor(0, 1);
//lcd.print(now() + 18000); //display unix time stamp on line 1
oldday = day();
oldtime = now();
prevphoto = analogRead(3);
if(check == true) {
//check == true now
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(hourFormat12(t));
lcd.print(":");
if(minute(t) < 10) {
lcd.print("0");
}
lcd.print(minute(t));
lcd.print(" ");
if(isAM(t) == true) {
lcd.print("AM");
}
else {
lcd.print("PM");
}
lcd.setCursor(0, 1);
lcd.print(now());
//delay(50);
}
//} //else {
}
else {
//int staticmillis = millis();
//while(staticmillis + 50 > millis()) {
delay(50);
//}
}
}
}

@ -1,180 +0,0 @@
int timeInterval = 0;
int analogPin = 5;
int drips = 0;
float grams = 30;
float totgrams = 0;
float phSense;
float mass = 39.99711;
bool titrate = false;
void setup() {
// put your setup code here, to run once:
if (drips > 0) {
grams = grams - (2.333333/20 * drips);
}
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(9, INPUT); //stream; 2 seconds
pinMode(10, OUTPUT);
pinMode(11, INPUT); //squirt; 0.5 seconds
pinMode(12, INPUT); //drip; 0.01 seconds
Serial.begin(9600);
digitalWrite(4, LOW); // start extended
}
void loop() {
timeInterval=0;
if(digitalRead(7) == 0) {
digitalWrite(4, HIGH); // up and down
delay(2500);
digitalWrite(3, HIGH); // number 3 is spring-loaded
delay(1500);
digitalWrite(4, LOW);
delay(250);
motor(255);
delay(3000);
titrate = true; //true, false for now
if(digitalRead(7) == 0 || titrate == false) {
Serial.println("CANCELLING");
stopmotor();
titrate = false;
digitalWrite(4, HIGH); // up and down
delay(2500);
digitalWrite(3, LOW); // number 3 is spring-loaded
delay(1500);
digitalWrite(4, LOW);
delay(500);
while(true) {
loop();
}
}
}
if(digitalRead(9) == 0)
{
motor(255);
delay(2000);
stopmotor();
//timeInterval = 175 * grams;
//totgrams = totgrams + grams;
}
else if(digitalRead(11) == 0 || titrate == true)
{
takepH();
float rate = 1 - (phSense / 7)*(phSense / 7);
while (rate > 0 && rate <=1) {
motor(255);
if(digitalRead(7) == 0) {
Serial.println("CANCELLING");
titrate = false;
stopmotor();
digitalWrite(4, HIGH); // up and down
delay(1500);
digitalWrite(3, LOW); // number 3 is spring-loaded
delay(2000);
digitalWrite(4, LOW);
while(true) {
loop();
}
}
if(rate > 0.8) {
rate = rate * 2;
}
if(phSense > 3) {
rate = 0.01;
}
timeInterval = rate * 175;
if (timeInterval < 30) {
timeInterval = 15;
}
totgrams = totgrams + timeInterval / 175;
digitalWrite(2, HIGH);
delay(timeInterval);
digitalWrite(2, LOW);
for(int i = 0; i < 10; i += 1){
delay(rate * 900);
if(digitalRead(7) == 0) {
Serial.println("CANCELLING");
titrate = false;
stopmotor();
digitalWrite(4, HIGH); // up and down
delay(1500);
digitalWrite(3, LOW); // spring-loaded
delay(2000);
digitalWrite(4, LOW);
while(true) {
loop();
}
}
}
takepH();
rate = 1 - (phSense / 7)*(phSense / 7);
delay(125);
}
Serial.println("done, returning pneumatics to holding point");
titrate = false;
stopmotor();
digitalWrite(4, HIGH); // up and down
delay(1500);
digitalWrite(3, LOW); // spring-loaded
delay(1500);
digitalWrite(4, LOW);
timeInterval = 0;
//timeInterval = 500;
//totgrams = totgrams + 2.857143;
}
else if (digitalRead(12) == 0 || drips > 0)
{
timeInterval = 15;
totgrams = totgrams + 2.333333/20;
drips --;
}
//Serial.print("Time Valve is open = ");
//Serial.println(timeInterval);
if(timeInterval > 0)
{
digitalWrite(2, HIGH);
delay(timeInterval);
digitalWrite(2, LOW);
takepH();
}
delay(50);
}
float takepH()
{
int samples = 30;
int aRead = 0;
for (int i = 0; i < samples ; i++)
{
aRead += analogRead(analogPin);
delay(100);
}
phSense = 0;
float phvolt = 5.0 * aRead/ (1023 * samples); // assuming 5V reference
phSense = 14 - phvolt/0.25; // convert voltage to pH
phSense = phSense - 1.3;
Serial.print("Time Interval = ");
Serial.println(timeInterval);
Serial.print("Analog in reading: ");
Serial.print(aRead/20); // print pH value on serial monitor
Serial.print(" - Calculated pH Level: ");
Serial.println(phSense, 2); // 1 = one decimal, 2 = two decimals, etc
Serial.print("Grams: ");
Serial.println(totgrams * 0.87, 4);
float molarity = 0.0025 * totgrams * 0.9 / 49.6;
Serial.print("Molarity of 20 mL of acid: ");
Serial.println(molarity, 10);
// removed the /10
delay(500);
}
void motor(int speed) {
analogWrite(10, speed);
//delay(timerun);
//analogWrite(10, 0);
}
void stopmotor() {
analogWrite(10, 0);
//delay(timerun);
//analogWrite(10, 0);
}

@ -1,48 +0,0 @@
int amber = 6;
int evil = 12;
int sensorinput = 3;
void setup()
{
pinMode(amber, OUTPUT);
pinMode(sensorinput, INPUT);
pinMode(evil, OUTPUT);
Serial.begin(9600);
}
void loop()
{
digitalWrite(evil, LOW);
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
int var = digitalRead(sensorinput);
Serial.println(var);
if (var == 0) {
digitalWrite(evil, LOW);
analogWrite(amber, fadeValue);
delay(30);
}
else {
analogWrite(amber, 0);
digitalWrite(evil, HIGH);
delay(30);
int var = digitalRead(sensorinput);
}
}
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
int var = digitalRead(sensorinput);
Serial.println(var);
if (var == 0) {
digitalWrite(evil, LOW);
analogWrite(amber, fadeValue);
delay(30);
}
else {
analogWrite(amber, 0);
digitalWrite(evil, HIGH);
delay(30);
int var = digitalRead(sensorinput);
}
}
}

@ -1,491 +0,0 @@
#include <IRremote.h>
int RECV_PIN1 = 13;
IRrecv irrecvmain(RECV_PIN1);
int RECV_PIN2 = 2;
int RECV_PIN3 = 26;
int RECV_PIN4 = 28;
int RECV_PIN5 = 30;
IRrecv irrecv2(RECV_PIN2);
IRrecv irrecv3(RECV_PIN3);
decode_results resultsmain;
decode_results results2;
decode_results results3;
IRrecv irrecv4(RECV_PIN4);
IRrecv irrecv5(RECV_PIN5);
decode_results results4;
decode_results results5;
int checkloop = 0;
int intright = 0;
int intleft = 0;
int intfor = 0;
int intback = 0;
int check1 = 0;
//driving
int slow = 0;
int LF = 6;
int LB = 9;
int RB = 11;
int RF = 10;
int echo1 = 5;
int trig1 = 12;
int echo2 = 3;
int trig2 = 7;
int echo3 = 22;
int trig3 = 23;
int echo4 = 24;
int trig4 = 25;
int echo5 = 41;
int trig5 = 40;
long duration1;
long duration2;
long duration3;
long duration4;
long duration5;
int distanceF1;
int distanceF2;
int distanceR1;
int distanceR2;
int distanceup;
int F1;
int F2;
int b1 = 8;
int b2 = 4;
bool forward = false;
bool backward = false;
bool left = false;
bool right = false;
bool stop = true;
bool sens2;
bool sens3;
bool sens4;
bool sens5;
bool stopping = false;
unsigned long s2millis;
unsigned long s3millis;
unsigned long s4millis;
unsigned long s5millis;
unsigned long current_time;
int s2l=36;
int s3l=37;
int s4l=38;
int s5l=39;
void setup()
{
Serial.begin(9600);
irrecvmain.enableIRIn(); // Start the reciever
irrecv2.enableIRIn();
irrecv3.enableIRIn();
irrecv4.enableIRIn();
irrecv5.enableIRIn();
pinMode(RB, OUTPUT);
pinMode(RF, OUTPUT);
pinMode(LB, OUTPUT);
pinMode(LF, OUTPUT);
pinMode(trig1, OUTPUT);
pinMode(echo1, INPUT);
pinMode(trig2, OUTPUT);
pinMode(echo2, INPUT);
pinMode(trig3, OUTPUT);
pinMode(echo3, INPUT);
pinMode(trig4, OUTPUT);
pinMode(echo4, INPUT);
pinMode(trig5, OUTPUT);
pinMode(echo5, INPUT);
pinMode(b1, INPUT);
pinMode(b2, INPUT);
pinMode(s2l, OUTPUT);
pinMode(s3l, OUTPUT);
pinMode(s4l, OUTPUT);
pinMode(s5l, OUTPUT);
}
void loop() {
//Serial.println(distanceup);
delay(5);
if (stop == true) {
left = false;
right = false;
forward = false;
backward = false;
}
mainloop();
check();
if (irrecvmain.decode(&resultsmain)) {
//Serial.println("Control Sensor ");
Serial.println(resultsmain.value);
irrecvmain.resume(); // Receive the next value
if (resultsmain.value == 4294967295) {
stop = true;
forward = false;
}
else {
if (resultsmain.value == 3937909453) {
stop = false;
forward = true;
}
}
}
if (irrecv2.decode(&results2)) {
//Serial.println("Sensor 2 ");
//Serial.println(results2.value);
irrecv2.resume(); // Receive the next value
s2millis = millis();
sens2=true;
//Serial.println("2");
digitalWrite(s2l, HIGH);
stop = false;
stopping = false;
}
if (irrecv3.decode(&results3)) {
//Serial.println("Sensor 3 ");
//Serial.println(results3.value);
irrecv3.resume(); // Receive the next value
s3millis = millis();
sens3=true;
//Serial.println("3");
digitalWrite(s3l, HIGH);
stop = false;
stopping = false;
}
if (irrecv4.decode(&results4)) {
//Serial.println("Sensor 4 ");
//Serial.println(results4.value);
irrecv4.resume(); // Receive the next value
s4millis = millis();
sens4=true;
//Serial.println("4");
digitalWrite(s4l, HIGH);
stop = false;
stopping = false;
}
if (irrecv5.decode(&results5)) {
//Serial.println("Sensor 5 ");
//Serial.println(results5.value);
irrecv5.resume(); // Receive the next value
s5millis = millis();
sens5=true;
//Serial.println("5");
digitalWrite(s5l, HIGH);
stop = false;
stopping = false;
}
}
void ir1() {
if (resultsmain.value == 3772778233) {
//forward = true;
left = false;
right = false;
backward = false;
intfor=intfor+1;
resultsmain.value = 0;
}
if (resultsmain.value == 3772810873) {
//backward = true;
left = false;
right = false;
forward = false;
intback=intback+1;
resultsmain.value = 0;
}
if (resultsmain.value == 3772819033) {
backward = false;
//left = true;
right = false;
forward = false;
intleft=intleft+1;
resultsmain.value = 0;
}
if (resultsmain.value == 3772794553) {
backward = false;
left = false;
//right = true;
forward = false;
intright=intright+1;
resultsmain.value = 0;
}
if (resultsmain.value == 3772793023) {
stop = true;
}
}
void mainloop()
{
//Serial.println(digitalRead(b1));
//Serial.println(digitalRead(b2));
if (digitalRead(b1) == 1) {
if (stop == true) {
forward = true;
stop=false;
stopping=false;
delay(250);
}
else {
stop=true;
delay(250);
}
}
if (digitalRead(b2) == 1) {
if (backward == false) {
backward = true;
forward = false;
left = false;
right = false;
delay(250);
}
else {
backward = false;
delay(250);
}
}
if (stop==false) {
digitalWrite(trig1, LOW);
delayMicroseconds(2);
digitalWrite(trig1, HIGH);
delayMicroseconds(10);
digitalWrite(trig1, LOW);
duration1 = pulseIn(echo1, HIGH);
distanceF1 = duration1*0.034/2;
digitalWrite(trig2, LOW);
delayMicroseconds(2);
digitalWrite(trig2, HIGH);
delayMicroseconds(10);
digitalWrite(trig2, LOW);
duration2 = pulseIn(echo2, HIGH);
distanceF2 = duration2*0.034/2;
F1=distanceF1+2;
F2=distanceF2+2;
//Serial.print("Distance F1: ");
Serial.print(distanceF1);
Serial.print(" ");
Serial.println(distanceF2);
}
//else {
// distanceF1 = 100;
//distanceF2 = 100;
//}
if (backward == true) {
digitalWrite(trig3, LOW);
delayMicroseconds(2);
digitalWrite(trig3, HIGH);
delayMicroseconds(10);
digitalWrite(trig3, LOW);
duration3 = pulseIn(echo3, HIGH);
distanceR1 = duration3*0.034/2;
digitalWrite(trig4, LOW);
delayMicroseconds(2);
digitalWrite(trig4, HIGH);
delayMicroseconds(10);
digitalWrite(trig4, LOW);
duration4 = pulseIn(echo4, HIGH);
distanceR2 = duration4*0.034/2;
//Serial.print("Distance R1: ");
//Serial.println(distanceR1);
//Serial.print("Distance R2: ");
//Serial.println(distanceR2);
//Serial.println("");
}
else {
distanceR1 = 100;
distanceR2 = 100;
}
}
void check()
{
//GO ---------------------------------------------------------------------------
if (stop == false) {
forward=true;
if (distanceF1<20) {
stopping=true;
forward = false;
Serial.print("f1<40");
if (distanceF1>distanceF2) {
Serial.print("f1?");
if (distanceF1>F2) {
Serial.print("f1");
right=true;
left=false;
forward=false;
}
else {
stop=true;
Serial.print("stop1");
}
}
else {
right=false;
Serial.print("no2");
if (distanceF2>distanceF1) {
Serial.print("f2?");
if (distanceF2>F1) {
left=true;
right=false;
Serial.print("f2");
forward=false;
}
else {
stop=true;
Serial.print("stop3");
}
}
else {
left=false;
Serial.println("no4");
}
}
}
else {
if (distanceF2<20) {
forward = false;
stopping=true;
Serial.print("f2<40");
if (distanceF1>distanceF2) {
Serial.print("f1?");
if (distanceF1>F2) {
right=true;
left=false;
Serial.print("f1");
forward=false;
}
else {
stop=true;
Serial.print("stop4");
}
}
else {
right=false;
Serial.print("no5");
if (distanceF2>distanceF1) {
Serial.print("f2?");
if (distanceF2>F1) {
left=true;
right=false;
Serial.print("f2");
forward=false;
}
else {
stop=true;
Serial.print("stop6");
}
}
else {
left=false;
Serial.print("no7");
}
}
}
else {
if (stopping = false) {
Serial.print("no8");
forward = true;
left=false;
right=false;
}
else {
Serial.print("stopping");
}
}
}
}
if (distanceF1<10) {
right=false;
left=false;
forward=false;
backward=true;
}
else {
if (distanceF2<10) {
right=false;
left=false;
forward=false;
backward=true;
}
else {
backward=false;
}
}
if (distanceup<15) {
stop = true;
}
if (stop == true) {
left = false;
right = false;
forward = false;
backward = false;
Serial.print("stop");
stopping = false;
}
else {
Serial.print("go");
}
if (distanceF1 > 25 && distanceF2 > 25 && forward == true) {
analogWrite(RF, 255);
analogWrite(LF, 255);
analogWrite(RB, 0);
analogWrite(LB, 0);
Serial.print("forward");
}
else {
if (distanceR1 > 35 && distanceR2 > 35 && backward == true) {
analogWrite(RF, 0);
analogWrite(LF, 0);
delay(200);
analogWrite(RB, 255);
analogWrite(LB, 255);
analogWrite(RF, 0);
analogWrite(LF, 0);
Serial.print("back");
}
else {
if (left == true) {
analogWrite(RF, 255);
analogWrite(LB, 255);
analogWrite(RB, 0);
analogWrite(LF, 0);
Serial.print("left");
}
else {
if (right == true) {
analogWrite(RB, 255);
analogWrite(LF, 255);
analogWrite(RF, 0);
analogWrite(LB, 0);
Serial.print("right");
}
else {
analogWrite(RF, 0);
analogWrite(LF, 0);
analogWrite(RB, 0);
analogWrite(LB, 0);
}
}
}
}
delay(100);
if (millis()-s2millis>=750) {
sens2=false;
digitalWrite(s2l, LOW);
}
if (millis()-s3millis>=750) {
sens3=false;
digitalWrite(s3l, LOW);
}
if (millis()-s4millis>=750) {
sens4=false;
digitalWrite(s4l, LOW);
}
if (millis()-s5millis>=750) {
sens5=false;
digitalWrite(s5l, LOW);
}
}
Loading…
Cancel
Save