This shows you the differences between two versions of the page.
pm:prj2023:alexau:mihai.ilinca [2023/05/23 22:33] mihai.ilinca [Software Design] |
pm:prj2023:alexau:mihai.ilinca [2023/05/28 17:15] (current) mihai.ilinca [Software Design] |
||
---|---|---|---|
Line 99: | Line 99: | ||
} | } | ||
- | int motor11 = 3; | + | int motor11 = PD3;//3; |
- | int motor12 = 4; | + | int motor12 = PD4;//4; |
- | int motor21 = 5; | + | int motor21 = PD5;//5; |
- | int motor22 = 6; | + | int motor22 = PD6;//6; |
- | int senzor1 = 7; | + | int senzor1 = PD7;//7; |
- | int senzor2 = 8; | + | int senzor2 = PB0;//8; |
- | int senzor3 = 9; | + | int senzor3 = PB1;//9; |
- | int senzor4 = 10; | + | int senzor4 = PB2;//10; |
int countdown = 0; | int countdown = 0; | ||
void moveForward() | void moveForward() | ||
{ | { | ||
- | digitalWrite(motor11,HIGH); | + | PORTD |= (1 << motor11); //digitalWrite(motor11,HIGH); |
- | digitalWrite(motor12,LOW); | + | PORTD &= ~(1 << motor12);//digitalWrite(motor12,LOW); |
- | digitalWrite(motor21,HIGH); | + | PORTD |= (1 << motor21);//digitalWrite(motor21,HIGH); |
- | digitalWrite(motor22,LOW); | + | PORTD &= ~(1 << motor22);//digitalWrite(motor22,LOW); |
} | } | ||
void moveLeft() | void moveLeft() | ||
{ | { | ||
- | digitalWrite(motor11,HIGH); | + | PORTD |= (1 << motor11);//digitalWrite(motor11,HIGH); |
- | digitalWrite(motor12,LOW); | + | PORTD &= ~(1 << motor12);//digitalWrite(motor12,LOW); |
- | digitalWrite(motor21,LOW); | + | PORTD &= ~(1 << motor21);//digitalWrite(motor21,LOW); |
- | digitalWrite(motor22,HIGH); | + | PORTD |= (1 << motor22);//digitalWrite(motor22,HIGH); |
} | } | ||
void moveRight() | void moveRight() | ||
{ | { | ||
- | digitalWrite(motor11,LOW); | + | PORTD &= ~(1 << motor11);//digitalWrite(motor11,LOW); |
- | digitalWrite(motor12,HIGH); | + | PORTD |= (1 << motor12);//digitalWrite(motor12,HIGH); |
- | digitalWrite(motor21,HIGH); | + | PORTD |= (1 << motor21);//digitalWrite(motor21,HIGH); |
- | digitalWrite(motor22,LOW); | + | PORTD &= ~(1 << motor22);//digitalWrite(motor22,LOW); |
} | } | ||
void Stop() | void Stop() | ||
{ | { | ||
- | digitalWrite(motor11,LOW); | + | PORTD &= ~(1 << motor11);//digitalWrite(motor11,LOW); |
- | digitalWrite(motor12,LOW); | + | PORTD &= ~(1 << motor12);//digitalWrite(motor12,LOW); |
- | digitalWrite(motor21,LOW); | + | PORTD &= ~(1 << motor21);//digitalWrite(motor21,LOW); |
- | digitalWrite(motor22,LOW); | + | PORTD &= ~(1 << motor22);//digitalWrite(motor22,LOW); |
} | } | ||
Line 152: | Line 152: | ||
void setup() { | void setup() { | ||
// put your setup code here, to run once: | // put your setup code here, to run once: | ||
- | pinMode(motor11,OUTPUT); | + | DDRD |= (1 << motor11);//pinMode(motor11,OUTPUT); |
- | pinMode(motor12,OUTPUT); | + | DDRD |= (1 << motor12);//pinMode(motor12,OUTPUT); |
- | pinMode(motor21,OUTPUT); | + | DDRD |= (1 << motor21);//pinMode(motor21,OUTPUT); |
- | pinMode(motor22,OUTPUT); | + | DDRD |= (1 << motor22);//pinMode(motor22,OUTPUT); |
- | pinMode(senzor1,INPUT); | + | DDRD &= ~(1 << senzor1);//pinMode(senzor1,INPUT); |
- | pinMode(senzor2,INPUT); | + | DDRB &= ~(1 << senzor2);//pinMode(senzor2,INPUT); |
- | pinMode(senzor3,INPUT); | + | DDRB &= ~(1 << senzor3);//pinMode(senzor3,INPUT); |
- | pinMode(senzor4,INPUT); | + | DDRB &= ~(1 << senzor4);//pinMode(senzor4,INPUT); |
change_side(); | change_side(); | ||
pinMode(12, OUTPUT); | pinMode(12, OUTPUT); | ||
pinMode(11, OUTPUT); | pinMode(11, OUTPUT); | ||
- | |||
- | Serial.begin(9600); | ||
configure_timer1(); | configure_timer1(); | ||
Line 181: | Line 179: | ||
} | } | ||
| | ||
- | int x = digitalRead(senzor3); | + | int x = PINB&(1 << senzor3);//digitalRead(senzor3); |
- | int y = digitalRead(senzor4); | + | int y = PINB&(1 << senzor4);//digitalRead(senzor4); |
if((x == 0 || y == 0) && countdown == 0) | if((x == 0 || y == 0) && countdown == 0) | ||
Line 193: | Line 191: | ||
Stop(); | Stop(); | ||
delay(2000); | delay(2000); | ||
- | int l = digitalRead(senzor2); | + | int l = PINB&(1 << senzor2);//digitalRead(senzor2); |
while(x != 0 || l == 0) | while(x != 0 || l == 0) | ||
{ | { | ||
moveRight(); | moveRight(); | ||
- | x = digitalRead(senzor3); | + | x = PINB&(1 << senzor3);//digitalRead(senzor3); |
- | l = digitalRead(senzor1); | + | l = PIND&(1 << senzor1);//digitalRead(senzor1); |
} | } | ||
Stop(); | Stop(); | ||
Line 211: | Line 209: | ||
} | } | ||
- | int r = digitalRead(senzor2); | + | int r = PINB&(1 << senzor2);//digitalRead(senzor2); |
- | int l = digitalRead(senzor1); | + | int l = PIND&(1 << senzor1);//digitalRead(senzor1); |
| | ||
if( l != 0) | if( l != 0) | ||
Line 229: | Line 227: | ||
} | } | ||
+ | </code> | ||
===== Rezultate Obţinute ===== | ===== Rezultate Obţinute ===== | ||
- | <note tip> | + | masina reuseste sa urmeze o linie, sa se invarte cand ajunge la capat de linie si sa o ia inapoi pe unde a venit |
- | Care au fost rezultatele obţinute în urma realizării proiectului vostru. | + | |
- | </note> | + | |
+ | https://www.youtube.com/watch?v=LBZnS3yhsbY | ||
===== Concluzii ===== | ===== Concluzii ===== | ||
- | Asadar si prin urmare grecii fac comert pe mare. Asadar si fara deci, nu este vorba despre greci | + | Am reusit sa implementez tot ce voiam sa implementez si proiectul a iesit asa cum imi planuiam. Unde nu a iesit cum ma asteptam este la timp si cost unde in ambele cazuri au fost mai mari decat ma asteptasem. Am avut probleme atat cu hardware-ul (piese stricate) cat si cu softwarul (bugs). Am consumat vre-o 3 baterii de 9V pentru a testa si a face probe la masina. All in all a fost fun si destul de diferit de temele/proiectele obisnuite din facultate |
===== Download ===== | ===== Download ===== | ||
Line 247: | Line 244: | ||
===== Jurnal ===== | ===== Jurnal ===== | ||
- | todo | + | 18.05.2023: finalizare motoare + caroseria masina |
- | <note tip> | + | |
- | Puteți avea și o secțiune de jurnal în care să poată urmări asistentul de proiect progresul proiectului. | + | 21.05.2023: finalizare functionalitate de urmarire linie |
- | </note> | + | |
+ | 23.05.2023: finalizare hardware | ||
+ | |||
===== Bibliografie/Resurse ===== | ===== Bibliografie/Resurse ===== |