1
Ардуино (Arduino) / Arduino код?
« -: Май 06, 2013, 11:48:41 pm »
Някой.
От тук може да видиш всички публикации на този потребител.
int motor1A = 1;
int motor1B = 2;
int motor1C = 3;
byte sekund=0;
byte minutes=0;
byte hour=0;
byte hour2=0;
byte day=0;
byte rootingDerection=0;
int sensePinT=0;
int lampPin=4;
int fanPin=7;
int errorLedPin=8;
void setup() {
pinMode(motor1A, OUTPUT);
pinMode(motor1B, OUTPUT);
pinMode(motor1C, OUTPUT);
pinMode(lampPin, OUTPUT);
pinMode(fanPin, OUTPUT);
pinMode(errorLedPin,OUTPUT);
}
void loop() {
if (day==21&&hour==12){
// тук трабва да се презапишат всички промнливи на 0.
}
if (sekund>59) {
sekund=0;
minutes=minutes+1;}
if(minutes>59){
minutes=0;
hour=hour+1;}
if(hour>24){hour=0;
day=day+1;
if (rootingDerection==0){
analogWrite(motor1C, 120);
digitalWrite(motor1A, HIGH);
digitalWrite(motor1B, LOW);
delay(200);
analogWrite(motor1C, 0);
digitalWrite(motor1A, LOW);
digitalWrite(motor1B, LOW);
delay(200);
rootingDerection=1;
}
else if (rootingDerection==1){
analogWrite(motor1C, 120);
digitalWrite(motor1A, HIGH);
digitalWrite(motor1B, LOW);
delay(200);
analogWrite(motor1C, 0);
digitalWrite(motor1A, LOW);
digitalWrite(motor1B, LOW);
delay(200);
rootingDerection==0;
}
else{digitalWrite(errorLedPin,HIGH);}
hour2=hour2+hour;
sekund=sekund+2;
}
if (hour>hour2){
if (rootingDerection==0){
analogWrite(motor1C, 120);
digitalWrite(motor1A, HIGH);
digitalWrite(motor1B, LOW);
delay(200);
analogWrite(motor1C, 0);
digitalWrite(motor1A, LOW);
digitalWrite(motor1B, LOW);
delay(200);
rootingDerection=1;
}
else if (rootingDerection==1){
analogWrite(motor1C, 120);
digitalWrite(motor1A, HIGH);
digitalWrite(motor1B, LOW);
delay(200);
analogWrite(motor1C, 0);
digitalWrite(motor1A, LOW);
digitalWrite(motor1B, LOW);
delay(200);
rootingDerection==0;
}
else{digitalWrite(errorLedPin,HIGH);}
hour2=hour2+hour;
sekund=sekund+2;
}
else{digitalWrite(errorLedPin,HIGH);}
int val=analogRead(sensePinT);
if (val<530) {
digitalWrite(lampPin,HIGH);
digitalWrite(fanPin,LOW);}
else if (val>650){
digitalWrite(lampPin,LOW);
digitalWrite(fanPin,HIGH);}
else{digitalWrite(errorLedPin,HIGH);}
delay(200);
sekund+1;
// И предполагам че тук трабва да се презапишат всички изпозвани променливи в EEPROM.
}
int motor1A = 1;
int motor1B = 2;
int motor1C = 3;
byte sekund=35;
byte minet=0;
byte hour=3;
byte hour2=1;
byte day=0;
byte rootingDerection=0;
int val;
void setup() {
pinMode(motor1A, OUTPUT);
pinMode(motor1B, OUTPUT);
pinMode(motor1C, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (hour>hour2){analogWrite(motor1C, 120);
digitalWrite(motor1A, HIGH);
digitalWrite(motor1B, LOW);
delay(200);
val=hour2+hour;
hour2=val;
sekund=sekund+2;
}
Serial.println(sekund);
Serial.println(val);
delay(200);
}