This shows you the differences between two versions of the page.
|
pm:prj2023:alexau:remote-car [2023/05/30 17:51] mihai_teodor.piele [Software Design] |
pm:prj2023:alexau:remote-car [2023/05/30 17:53] (current) mihai_teodor.piele [Rezultate Obţinute] |
||
|---|---|---|---|
| Line 53: | Line 53: | ||
| * IRremote.h -> folosit pentru a interactiona cu modulul IR si a capta datele primite. | * IRremote.h -> folosit pentru a interactiona cu modulul IR si a capta datele primite. | ||
| - | ---- | ||
| - | Demo: | ||
| - | * https://imgur.com/b8VoxXf | ||
| - | |||
| - | {{:pm:prj2023:alexau:b1.jpeg?nolink&300|}} | ||
| - | {{:pm:prj2023:alexau:b2.jpeg?nolink&300|}} | ||
| - | {{:pm:prj2023:alexau:b3.jpeg?nolink&300|}} | ||
| ---- | ---- | ||
| Line 66: | Line 59: | ||
| Cod: | Cod: | ||
| - | <code>To be posted!</code> | + | <code cpp>#include <Arduino.h> |
| + | #include <IRremote.h> | ||
| + | #include <Servo.h> | ||
| + | |||
| + | IRrecv IR(3); | ||
| + | Servo myservo; | ||
| + | // pinii motoarelor | ||
| + | int moto1 = 4; | ||
| + | int moto2 = 5; | ||
| + | int moto11 = 6; | ||
| + | int moto22 = 7; | ||
| + | // pinul pentru becuri | ||
| + | int bec = 13; | ||
| + | // pozitia initiala a carmei, pt a merge stanga/dreapta | ||
| + | int pos = 90; | ||
| + | |||
| + | void setup() { | ||
| + | IR.enableIRIn(); | ||
| + | // pentru a controla componentele setez pinii placutei ca output | ||
| + | pinMode(bec, OUTPUT); | ||
| + | pinMode(moto1, OUTPUT); | ||
| + | pinMode(moto2, OUTPUT); | ||
| + | pinMode(moto11, OUTPUT); | ||
| + | pinMode(moto22, OUTPUT); | ||
| + | myservo.attach(9); | ||
| + | Serial.begin(9600); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | if(IR.decode()) | ||
| + | { // citesc informatia de la modul IR si in functie de comanda, fac o actiune | ||
| + | Serial.println(IR.decodedIRData.decodedRawData,HEX); | ||
| + | if(IR.decodedIRData.decodedRawData == 0xEA15FF00) | ||
| + | { // aprind bec | ||
| + | digitalWrite(bec, HIGH); | ||
| + | } | ||
| + | |||
| + | if(IR.decodedIRData.decodedRawData == 0xF807FF00) | ||
| + | { // sting bec | ||
| + | digitalWrite(bec, LOW); | ||
| + | } | ||
| + | |||
| + | if(IR.decodedIRData.decodedRawData == 0xE718FF00) | ||
| + | { // merg fata | ||
| + | digitalWrite(moto1, HIGH); | ||
| + | digitalWrite(moto2, LOW); | ||
| + | digitalWrite(moto11, LOW); | ||
| + | digitalWrite(moto22, HIGH); | ||
| + | } | ||
| + | |||
| + | if(IR.decodedIRData.decodedRawData == 0xAD52FF00) | ||
| + | { //merg spate | ||
| + | digitalWrite(moto1, LOW); | ||
| + | digitalWrite(moto2, HIGH); | ||
| + | digitalWrite(moto11, HIGH); | ||
| + | digitalWrite(moto22, LOW); | ||
| + | } | ||
| + | |||
| + | if(IR.decodedIRData.decodedRawData == 0xE31CFF00) | ||
| + | { //opresc tot | ||
| + | digitalWrite(moto1, LOW); | ||
| + | digitalWrite(moto2, LOW); | ||
| + | digitalWrite(moto11, LOW); | ||
| + | digitalWrite(moto22, LOW); | ||
| + | //readuc carma la pozitia de inainte | ||
| + | myservo.write(90); | ||
| + | } | ||
| + | |||
| + | if(IR.decodedIRData.decodedRawData == 0xF708FF00) | ||
| + | { // cotesc stanga | ||
| + | myservo.write(25); | ||
| + | } | ||
| + | |||
| + | if(IR.decodedIRData.decodedRawData == 0xA55AFF00) | ||
| + | { // cotesc dreapta | ||
| + | myservo.write(145); | ||
| + | } | ||
| + | //delay la citirea comenzilor de la IR | ||
| + | delay(1500); | ||
| + | IR.resume(); | ||
| + | } | ||
| + | } | ||
| + | </code> | ||
| Line 74: | Line 149: | ||
| <note tip> | <note tip> | ||
| - | Care au fost rezultatele obţinute în urma realizării proiectului vostru. | + | |
| + | |||
| + | |||
| + | Demo: | ||
| + | * https://imgur.com/b8VoxXf | ||
| + | |||
| + | {{:pm:prj2023:alexau:b1.jpeg?nolink&300|}} | ||
| + | {{:pm:prj2023:alexau:b2.jpeg?nolink&300|}} | ||
| + | {{:pm:prj2023:alexau:b3.jpeg?nolink&300|}} | ||
| + | |||
| </note> | </note> | ||