Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "MeMCore.h"
- MeDCMotor stang(M1);
- MeDCMotor drept(M2);
- MeLineFollower line(PORT_2);
- MeUltrasonicSensor sonic(PORT_3);
- int distanta;
- int stare;
- MeIR ir;
- int ok;
- int Stefan=0;
- int m=0;
- uint32_t value = 0x00;
- void inainte () {
- stang.run(-150);
- drept.run(150);
- }
- void atac () {
- stang.run(-255);
- drept.run(255);
- }
- void inapoi () {
- stang.run(255);
- drept.run(-255);
- }
- void dreapta () {
- stang.run(255);
- drept.run(0);
- }
- void stanga () {
- stang.run(0);
- drept.run(-255);
- }
- void oprire () {
- stang.run(0);
- drept.run(0);
- }
- void sumo() {
- distanta = sonic.distanceCm();
- int stare = line.readSensors();
- switch (stare) {
- case 0:{
- if (distanta < 20) {
- atac(); }
- else inainte(); break;}
- case 1: inapoi(); delay(600);dreapta();delay(300); ok = 1; break;
- case 2: inapoi(); delay(600);stanga();delay(300);ok = 2; break;
- case 3: inapoi(); delay(600);stanga();delay(300);break;
- //if (ok == 1){inapoi(); delay(600);dreapta();delay(300);}
- // if (ok == 2){inapoi; delay(600);stanga();delay(300);}
- //if(ok == 0) {inapoi; delay(600);stanga();delay(300);}
- }}
- /*distanta = sonic.distanceCm();
- if (distanta < 20) {
- atac(); }
- else inainte();
- }
- */
- void setup() {
- ir.begin();}
- void loop() {
- if (ir.decode()) {
- value = (ir.value >> 16 & 0xFF );
- }
- switch (value) {
- case 0x44 : if (Stefan==0)
- {dreapta();
- delay(600);
- Stefan=Stefan+1;}
- sumo();
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement