kramann.info
© Guido Kramann

Login: Passwort:










20 Bau eines Autonomen Schwarmvehikels

20 Construction of an autonomous swarm vehicle (EN google-translate)

20 Budowa autonomicznego pojazdu rój (PL google-translate)

Um den Motortreiber zwischen den Pins des Arduino-Micro unterzubringen, muß es möglich sein, die Pins A0 bis A5 auch als digitale Ausgänge zu verwenden.

To accommodate the motor driver between the pins of the Arduino Micro, It must be possible to use the pins A0 to A5 as digital outputs.

Aby pomieścić sterownik silnika między pinami Arduino Micro, Musi być możliwe użycie pinów A0 do A5 jako wyjść cyfrowych.

Hierzu ein Test:

For this a test:

Do tego testu:

int zustand = 0;
//A0 = D18
//A1 = D19
//A2 = D20
//A3 = D21
//A4 = D22
//A5 = D23
//A6 = D24
//A7 = D25
//A8 = D26
//A9 = D27
//A10 = D28
//A11 = D29
void setup() 
{
  pinMode(18,OUTPUT);  
  pinMode(19,OUTPUT);  
  //pinMode(3,OUTPUT);  
  //tone(3,710);
  
  
}

void loop() 
{
  digitalWrite(18,1);    
  digitalWrite(19,1);    
  delay(800);
  digitalWrite(18,0);    
  digitalWrite(19,0);    
  delay(800);
}

Code 20-1: Testweise Pin A0 und A1 als digitale Ausgänge verwenden.

Basisprogramm - alles inaktiv, LED D13 blinkt

Basic program - all inactive, LED D13 flashes

Podstawowy program - wszystkie nieaktywne, dioda LED D13 miga

int zustand = 0;
//A0 = D18
//A1 = D19
//A2 = D20
//A3 = D21
//A4 = D22
//A5 = D23
//A6 = D24
//A7 = D25
//A8 = D26
//A9 = D27
//A10 = D28
//A11 = D29
void setup() 
{
  pinMode(18,INPUT);  //A0
  pinMode(19,INPUT);  //A1  
  pinMode(20,INPUT);  //A2  
  pinMode(21,INPUT);  //A3  
  pinMode(22,INPUT);  //A4  
  pinMode(23,INPUT);  //A5

  pinMode(2,INPUT);  //D2
  pinMode(3,INPUT);  //D3
  pinMode(4,INPUT);  //D4
  pinMode(5,INPUT);  //D5
  pinMode(6,INPUT);  //D6
  pinMode(7,INPUT);  //D7
  pinMode(8,INPUT);  //D8
  pinMode(9,INPUT);  //D9
  
  pinMode(13,OUTPUT); //LED  
}

void loop() 
{
  digitalWrite(13,1);    
  delay(500);
  digitalWrite(13,0);    
  delay(500);
}

Code 20-2: Basisprogramm - alles inaktiv, LED D13 blinkt

Analoge Werte lesen und auf die serielle Schnittstelle schreiben

Read analog values ​​and write to the serial interface

Odczytaj wartości analogowe i napisz do interfejsu szeregowego

int sensorwert=0;
//A0 = D18
//A1 = D19
//A2 = D20
//A3 = D21
//A4 = D22
//A5 = D23
//A6 = D24
//A7 = D25
//A8 = D26
//A9 = D27
//A10 = D28
//A11 = D29
void setup() 
{
  pinMode(18,INPUT);  //A0
  pinMode(19,INPUT);  //A1  
  pinMode(20,INPUT);  //A2  
  pinMode(21,INPUT);  //A3  
  pinMode(22,INPUT);  //A4  
  pinMode(23,INPUT);  //A5

  pinMode(2,INPUT);  //D2
  pinMode(3,INPUT);  //D3
  pinMode(4,INPUT);  //D4
  pinMode(5,INPUT);  //D5
  pinMode(6,INPUT);  //D6
  pinMode(7,INPUT);  //D7
  pinMode(8,INPUT);  //D8
  pinMode(9,INPUT);  //D9
  
  pinMode(13,OUTPUT); //LED 
 
  Serial.begin(9600);   

  //LINKER MOTOR:
  
}

void loop() 
{
  sensorwert = analogRead(11);
 
  Serial.write(48+(sensorwert/1000)%10);
  Serial.write(48+(sensorwert/100)%10);
  Serial.write(48+(sensorwert/10)%10);
  Serial.write(48+(sensorwert/1)%10);
  Serial.write('
');
  Serial.write('
');
  
  digitalWrite(13,1);    
  delay(250);
  digitalWrite(13,0);    
  delay(250);
}

Code 20-3: Analoge Werte lesen und auf die serielle Schnittstelle schreiben

Vorwärtsfahrt-Test

Forward driving test

Test jazdy do przodu

int sensorwert=0;
//A0 = D18
//A1 = D19
//A2 = D20
//A3 = D21
//A4 = D22
//A5 = D23
//A6 = D24
//A7 = D25
//A8 = D26
//A9 = D27
//A10 = D28
//A11 = D29
void setup() 
{
  pinMode(18,INPUT);  //A0
  pinMode(19,INPUT);  //A1  
  pinMode(20,INPUT);  //A2  
  pinMode(21,INPUT);  //A3  
  pinMode(22,INPUT);  //A4  
  pinMode(23,INPUT);  //A5

  pinMode(2,INPUT);  //D2
  pinMode(3,INPUT);  //D3
  pinMode(4,INPUT);  //D4
  pinMode(5,INPUT);  //D5
  pinMode(6,INPUT);  //D6
  pinMode(7,INPUT);  //D7
  pinMode(8,INPUT);  //D8
  pinMode(9,INPUT);  //D9
  
  pinMode(13,OUTPUT); //LED 
 
  Serial.begin(9600);   

  //Rechte Motorseite:
  pinMode(10,OUTPUT);  //Enable 1, L293_PIN1
  pinMode(8,OUTPUT);   //Input 2, L293_PIN7
  pinMode(3,OUTPUT);   //Input 1, L293_PIN2
  
  digitalWrite(3,1);    
  digitalWrite(8,0);    
  analogWrite(10,0);
  
  //Linke Motorseite:
  pinMode(13,OUTPUT);  //Enable 2, L293_PIN9
  pinMode(19,OUTPUT);   //A1 Input 3, L293_PIN15
  pinMode(11,OUTPUT);   //Input 4, L293_PIN10
  
  digitalWrite(19,1);    
  digitalWrite(11,0);    
  analogWrite(13,0);
  
}

void loop() 
{
  sensorwert = analogRead(11);
 
  Serial.write(48+(sensorwert/1000)%10);
  Serial.write(48+(sensorwert/100)%10);
  Serial.write(48+(sensorwert/10)%10);
  Serial.write(48+(sensorwert/1)%10);
  Serial.write('
');
  Serial.write('
');
  
  digitalWrite(13,1);    
  analogWrite(10,0);
  analogWrite(13,255);
  delay(250);
  digitalWrite(13,0);    
  analogWrite(10,255);
  analogWrite(13,0);  
  delay(250);
}

Code 20-4: Vorwärtsfahrt-Test

An einer Wand entlang fahren

Drive along a wall

Jedź wzdłuż ściany

int sensorwert=0;
int regler=0;
//A0 = D18
//A1 = D19
//A2 = D20
//A3 = D21
//A4 = D22
//A5 = D23
//A6 = D24
//A7 = D25
//A8 = D26
//A9 = D27
//A10 = D28
//A11 = D29
void setup() 
{
  pinMode(18,INPUT);  //A0
  pinMode(19,INPUT);  //A1  
  pinMode(20,INPUT);  //A2  
  pinMode(21,INPUT);  //A3  
  pinMode(22,INPUT);  //A4  
  pinMode(23,INPUT);  //A5

  pinMode(2,INPUT);  //D2
  pinMode(3,INPUT);  //D3
  pinMode(4,INPUT);  //D4
  pinMode(5,INPUT);  //D5
  pinMode(6,INPUT);  //D6
  pinMode(7,INPUT);  //D7
  pinMode(8,INPUT);  //D8
  pinMode(9,INPUT);  //D9
  
  pinMode(13,OUTPUT); //LED 
 
//  Serial.begin(9600);   

  //Rechte Motorseite:
  pinMode(10,OUTPUT);  //Enable 1, L293_PIN1
  pinMode(8,OUTPUT);   //Input 2, L293_PIN7
  pinMode(3,OUTPUT);   //Input 1, L293_PIN2
  
  digitalWrite(3,1);    
  digitalWrite(8,0);    
  analogWrite(10,0);
  
  //Linke Motorseite:
  pinMode(13,OUTPUT);  //Enable 2, L293_PIN9
  pinMode(19,OUTPUT);   //A1 Input 3, L293_PIN15
  pinMode(11,OUTPUT);   //Input 4, L293_PIN10
  
  digitalWrite(19,1);    
  digitalWrite(11,0);    
  analogWrite(13,0);
  
}

void loop() 
{
  sensorwert = analogRead(11);
 
  regler = 250-sensorwert;

  if(regler>100)
      regler=100;
  else if(regler<-100)    
      regler=-100;
  regler/=32;  
  /*
  Serial.write(48+(sensorwert/1000)%10);
  Serial.write(48+(sensorwert/100)%10);
  Serial.write(48+(sensorwert/10)%10);
  Serial.write(48+(sensorwert/1)%10);
  Serial.write('
');
  Serial.write('
');
  */
  //digitalWrite(13,1);    
  analogWrite(13,255-regler);
  
  //digitalWrite(13,0);    
  analogWrite(10,255+regler);
  
  delay(10);
  
}

Code 20-5: An einer Wand entlang fahren