to sum up the control scheme for Motor1:
•Motor1 Action •Input1 •Input2 •EnableA
Run forward High Low High
Run backwards Low High High
Stop High High High
Stop Low Low High
Freewheel don't care don't care Low
Wednesday, March 16, 2011
L298 meets Arduino Mega
Source
void setup() {
Serial.begin(9600); // go go serial power
pinMode(6, INPUT); // this simulates the two power pins on
pinMode(7, INPUT); // the electric motor, like a virtual motor
pinMode(14, OUTPUT); //logic signal 1
pinMode(15, OUTPUT); //logic signal 2
pinMode(18, OUTPUT); // enable hbridge
digitalWrite(18,LOW); //turn off
digitalWrite(14,HIGH); //send signal1
digitalWrite(15,HIGH); //send signal2
digitalWrite(18,HIGH); //turn on
Serial.println(digitalRead(6)); //get output
Serial.println(digitalRead(7));
Serial.println();
digitalWrite(18,LOW); //turn off
digitalWrite(14,HIGH); //send signal1
digitalWrite(15,LOW); //send signal2
digitalWrite(18,HIGH); //turn on
Serial.println(digitalRead(6)); //get output
Serial.println(digitalRead(7));
Serial.println();
digitalWrite(18,LOW); //turn off
digitalWrite(14,LOW); //send signal1
digitalWrite(15,HIGH); //send signal2
digitalWrite(18,HIGH); //turn on
Serial.println(digitalRead(6)); //get output
Serial.println(digitalRead(7));
Serial.println();
digitalWrite(18,LOW); //turn off
digitalWrite(14,LOW); //send signal1
digitalWrite(15,LOW); //send signal2
digitalWrite(18,HIGH); //turn on
Serial.println(digitalRead(6)); //get output
Serial.println(digitalRead(7));
Serial.println();
}
void loop() {
// Please use common sense when trying 'internet code'.
// I refuse to be held accountable for any
// damages this code may or may not cause.
// Shameless and removable author webpage inclusion:
// http://software.o-o.ro
}
void setup() {
Serial.begin(9600); // go go serial power
pinMode(6, INPUT); // this simulates the two power pins on
pinMode(7, INPUT); // the electric motor, like a virtual motor
pinMode(14, OUTPUT); //logic signal 1
pinMode(15, OUTPUT); //logic signal 2
pinMode(18, OUTPUT); // enable hbridge
digitalWrite(18,LOW); //turn off
digitalWrite(14,HIGH); //send signal1
digitalWrite(15,HIGH); //send signal2
digitalWrite(18,HIGH); //turn on
Serial.println(digitalRead(6)); //get output
Serial.println(digitalRead(7));
Serial.println();
digitalWrite(18,LOW); //turn off
digitalWrite(14,HIGH); //send signal1
digitalWrite(15,LOW); //send signal2
digitalWrite(18,HIGH); //turn on
Serial.println(digitalRead(6)); //get output
Serial.println(digitalRead(7));
Serial.println();
digitalWrite(18,LOW); //turn off
digitalWrite(14,LOW); //send signal1
digitalWrite(15,HIGH); //send signal2
digitalWrite(18,HIGH); //turn on
Serial.println(digitalRead(6)); //get output
Serial.println(digitalRead(7));
Serial.println();
digitalWrite(18,LOW); //turn off
digitalWrite(14,LOW); //send signal1
digitalWrite(15,LOW); //send signal2
digitalWrite(18,HIGH); //turn on
Serial.println(digitalRead(6)); //get output
Serial.println(digitalRead(7));
Serial.println();
}
void loop() {
// Please use common sense when trying 'internet code'.
// I refuse to be held accountable for any
// damages this code may or may not cause.
// Shameless and removable author webpage inclusion:
// http://software.o-o.ro
}
Tuesday, March 15, 2011
hello world
//digital set to high or low
//46. CSA (PNK)
//47. CSB (PPL)
//48. IN2 (PNK) HIGH
//49. IN4 (PPL)
//50. ENA (PNK) HIGH motor on.off
//51. ENB (PPL) HIGH motor on.off
//52. IN1 (PNK) LOW
//53. IN3 (PPL)
int a = 48;
int b = 52;
int en = 50;
int c = 49;
int d = 53;
int ne = 51;
int csa = 46;
int csb = 47;
void setup()
{
pinMode(b,OUTPUT);
pinMode(a,OUTPUT);
pinMode(en,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
pinMode(ne,OUTPUT);
}
void loop(){
//foward
digitalWrite(en,HIGH);
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(ne,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,LOW);
//reverse
// digitalWrite(en,HIGH);
// digitalWrite(a,LOW);
// digitalWrite(b,HIGH);
// digitalWrite(ne,HIGH);
// digitalWrite(c,LOW);
// digitalWrite(d,HIGH);
}
//46. CSA (PNK)
//47. CSB (PPL)
//48. IN2 (PNK) HIGH
//49. IN4 (PPL)
//50. ENA (PNK) HIGH motor on.off
//51. ENB (PPL) HIGH motor on.off
//52. IN1 (PNK) LOW
//53. IN3 (PPL)
int a = 48;
int b = 52;
int en = 50;
int c = 49;
int d = 53;
int ne = 51;
int csa = 46;
int csb = 47;
void setup()
{
pinMode(b,OUTPUT);
pinMode(a,OUTPUT);
pinMode(en,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
pinMode(ne,OUTPUT);
}
void loop(){
//foward
digitalWrite(en,HIGH);
digitalWrite(a,HIGH);
digitalWrite(b,LOW);
digitalWrite(ne,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,LOW);
//reverse
// digitalWrite(en,HIGH);
// digitalWrite(a,LOW);
// digitalWrite(b,HIGH);
// digitalWrite(ne,HIGH);
// digitalWrite(c,LOW);
// digitalWrite(d,HIGH);
}
Subscribe to:
Posts (Atom)