• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
SMARS- zasilanie arduino Vin Gnd
#1
Cześć, chciałem sobie zrobić takiego oto robota. Podłączyłem wszystko według tego schematu:

[/url]
[Obrazek: 35646189_1978617645543864_54361436971398...e=5BBA00CF]

Jednak nie działa. Dioda na płytce L293D świeci, na arduino również ale bardzo słabo i nic się dzieje dopóki nie podłącze zasilacza lub usb do arduino, wtedy wszystko działa. Próbowałem z dwiema różnymi płytkami adfruit oraz na 2 różnych klonach arduino Uno, jedna na ch340 druga to Funduino Uno. Używałem też [url=https://fr.aliexpress.com/item/L298P-Motor-Driver-Module-H-bridge-Drive-Shield-Expansion-Board-High-Power-DC-Stepper-Motor-Controller/32829624110.html?spm=a2g0w.search0204.3.20.0c9wS7&ws_ab_test=searchweb0_0,searchweb201602_1_10152_10151_10065_10344_10068_10342_10343_10340_10341_10084_10083_10613_10305_10304_10615_10307_10614_10306_10302_10059_10314_10184_10534_100031_10604_10103_10142,searchweb201603_40,ppcSwitch_5_ppcChannel&algo_expid=fff51d57-4619-410a-a347-78211a32184d-2&algo_pvid=fff51d57-4619-410a-a347-78211a32184d&priceBeautifyAB=0]takiej
płytki ale efekt był ten sam, działa tylko gdy podłączę arduino osobno do zasilania. Bateria jest ok, próbowałem też zasilać to zasilaczem 9V 1A.

Kody, których używam:
Kod:
#include <AFMotor.h"> //import your motor shield library
AF_DCMotor motor1(1); // set up motor1. motor1 is the name, and (1) is the port
AF_DCMotor motor2(2); // set up motor2. motor2 is the name, and (2) is the port
#define trigPin 7 // define the pins of your sensor
#define echoPin 6

void setup() {
motor1.setSpeed(255); //set the speed of the motors, between 0-255
motor2.setSpeed (250);

Serial.begin(9600); // begin serial communitication
pinMode(trigPin, OUTPUT);// set the trig pin to output (Send sound waves)
pinMode(echoPin, INPUT);// set the echo pin to input (recieve sound waves)
}

void loop() {
long duration, distance; // start the scan
digitalWrite(trigPin, LOW);
delayMicroseconds(2); // delays are required for a succesful sensor operation.

digitalWrite(trigPin, HIGH);
delayMicroseconds(10); //this delay is required as well!

digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 58.2;// convert the distance to centimeters. 29.1
delay (50);

motor1.run(BACKWARD);
motor2.run(FORWARD);
Serial.print ("distance");

if (distance < 10)/*if there's an obstacle 10 centimers, ahead, do the following: */ {

Serial.print ("distance");

motor1.run(FORWARD);
motor2.run(FORWARD);
}
}

i ten z bluetooth

Kod:
#include <SoftwareSerial.h>

SoftwareSerial HC06(0, 1); // RX, TX
const char DOUT_LED = 2;
String messageRecu;

//MOTEUR//
int E1 = 10;
int M1 = 12;                                                                    // moteur de gauche
int E2 = 11;
int M2 = 13;                                                                    // moteur de droite
int value = 255 ;
int none = 0;

//IR SENSOR//
const char DOUT_TRIGGER = 7;                                                    //Vert
const char DIN_ECHO = 6 ;                                                       //Bleu
int distance;

void setup() {
 Serial.begin(9600);
 HC06.begin(9600);
 pinMode(DOUT_LED, OUTPUT);
 digitalWrite(DOUT_LED, LOW);
 pinMode(M1, OUTPUT);                                                            // Moteur de gauche
 pinMode(M2, OUTPUT);                                                            // Moteur de droite
 pinMode(DOUT_TRIGGER, OUTPUT);                                                  // Sonde sorti
 pinMode(DIN_ECHO, INPUT);                                                       // Sonde entré

}

void loop()
{
     while(HC06.available())
   {
     delay(3);
     char c = HC06.read();
     messageRecu += c;
   }

   if (messageRecu.length() >0)
   {
     Serial.println(messageRecu);

     {  Serial.println("Stop");
       digitalWrite(M1,HIGH);
       digitalWrite(M2,HIGH);
       analogWrite(E1, none);
       analogWrite(E2, none);
     }

     if (messageRecu == "Avance")
       {
         Serial.println("Avance");
         digitalWrite(M1,LOW);
         digitalWrite(M2,LOW);
         analogWrite(E1, value);
         analogWrite(E2, value);
       }

     if (messageRecu == "Recule")
       {
         Serial.println("Recule");
         digitalWrite(M1,HIGH);
         digitalWrite(M2,HIGH);
         analogWrite(E1, value);
         analogWrite(E2, value);
       }

     if (messageRecu == "Droite")
         {
           Serial.println("Droite");
           digitalWrite(M1,HIGH);
           digitalWrite(M2,LOW);
           analogWrite(E1, value);
           analogWrite(E2, value);
         }

     if (messageRecu == "Gauche")
         {
           Serial.println("Gauche");
           digitalWrite(M1,LOW);
           digitalWrite(M2,HIGH);
           analogWrite(E1, value);
           analogWrite(E2, value);
         }

     if (messageRecu == "Stop")
         {
           Serial.println("Stop");
           digitalWrite(M1,HIGH);
           digitalWrite(M2,HIGH);
           analogWrite(E1, none);
           analogWrite(E2, none);
         }

     messageRecu="";
   }
}
 
Odpowiedź
  


Wiadomości w tym wątku
SMARS- zasilanie arduino Vin Gnd - przez Rafix095 - 22-06-2018, 19:02
RE: SMARS- zasilanie arduino Vin Gnd - przez es2 - 23-06-2018, 12:50
RE: SMARS- zasilanie arduino Vin Gnd - przez es2 - 24-06-2018, 08:59

Skocz do:


Przeglądający: 1 gości