User Tools

Site Tools


code

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
code [2014/01/31 21:09]
jgensler8
code [2014/02/14 19:13] (current)
jgensler8
Line 1: Line 1:
 +====== Headline ======
 <​code>​ <​code>​
- 
 /* /*
   SoftwareSerial to ttyAMA0   SoftwareSerial to ttyAMA0
Line 8: Line 8:
  
 #define PULSE_A 3 #define PULSE_A 3
-#define PULSE_B ​4 +#define PULSE_B ​11 
-#define DIR_A 5 +#define DIR_A 12 
-#define DIR_B 6+#define DIR_B 13
  
 SoftwareSerial mySerial(8, 9); // RX, TX SoftwareSerial mySerial(8, 9); // RX, TX
 char serialIn; char serialIn;
 int movementTime = 1000; int movementTime = 1000;
-int basicPower = 100;+int basicPower = 50;
  
 void setup()  ​ void setup()  ​
Line 33: Line 33:
   pinMode( DIR_B, OUTPUT);   pinMode( DIR_B, OUTPUT);
   ​   ​
 +  digitalWrite( PULSE_A, LOW);
 +  digitalWrite( PULSE_B, LOW);
 +  digitalWrite( DIR_A, LOW);
 +  digitalWrite( DIR_B, LOW);
 +  ​
 +  /*
   analogWrite( PULSE_A, 100);   analogWrite( PULSE_A, 100);
   analogWrite( PULSE_B, 100);   analogWrite( PULSE_B, 100);
 +  */
 } }
  
Line 46: Line 53:
     }     }
     else if( serialIn == '​-'​){     else if( serialIn == '​-'​){
-      goReverse( movementTime,​ basicPower);​+      ​//goReverse( movementTime,​ basicPower);​
     }     }
     else if( serialIn == '>'​){     else if( serialIn == '>'​){
-     turnRight();​+      ​turnRight(movementTime,​ basicPower);
     }     }
     else if( serialIn == '<'​){     else if( serialIn == '<'​){
-      turnLeft();+      turnLeft(movementTime,​ basicPower);
     }      } 
   }   }
Line 62: Line 69:
   digitalWrite( PULSE_A, HIGH);   digitalWrite( PULSE_A, HIGH);
   digitalWrite( PULSE_B, HIGH);   digitalWrite( PULSE_B, HIGH);
-  ​//delay(time);​+  delay(time);​
   analogWrite( PULSE_A, power);   analogWrite( PULSE_A, power);
   analogWrite( PULSE_B, power);   analogWrite( PULSE_B, power);
-  ​delay(time);​ +  //​delay(time);​
-  digitalWrite( PULSE_A, HIGH); +
-  digitalWrite( PULSE_B, HIGH); +
-  ​//delay( time); +
-  digitalWrite( PULSE_A, LOW); +
-  digitalWrite( PULSE_B, LOW);+
   analogWrite( PULSE_A, 0);   analogWrite( PULSE_A, 0);
   analogWrite( PULSE_B, 0);   analogWrite( PULSE_B, 0);
Line 77: Line 79:
 } }
  
 +/*
 +//as far as we know, this will never work...
 void goReverse( int time, int power){ void goReverse( int time, int power){
-  ​+  ​digitalWrite( PULSE_A, HIGH); 
 +  digitalWrite( PULSE_B, HIGH); 
 +  delay(time);​ 
 +  analogWrite( PULSE_A, power); 
 +  analogWrite( PULSE_B, power); 
 +  //​delay(time);​ 
 +  analogWrite( PULSE_A, 0); 
 +  analogWrite( PULSE_B, 0); 
 +  digitalWrite( PULSE_A, LOW); 
 +  digitalWrite( PULSE_B, LOW);
 } }
 +*/
  
-void turnLeft(){ +void turnLeft(int time, int power){ 
-  ​+  ​digitalWrite( PULSE_A, HIGH); 
 +  delay(time);​ 
 +  analogWrite( PULSE_A, power); 
 +  //​delay(time);​ 
 +  analogWrite( PULSE_A, 0); 
 +  digitalWrite( PULSE_A, LOW);
 } }
  
-void turnRight(){ +void turnRight(int time, int power){ 
- +  ​digitalWrite( PULSE_B, HIGH); 
 +  delay(time);​ 
 +  analogWrite( PULSE_B, power); 
 +  //​delay(time);​ 
 +  analogWrite( PULSE_B, 0); 
 +  digitalWrite( PULSE_B, LOW);
 } }
- 
 </​code>​ </​code>​
code.txt · Last modified: 2014/02/14 19:13 by jgensler8