Arduino Projects: Difference between revisions
→Bluetooth Controlled RC Car
(→Running Lights with Speed Control: matrix clock) |
|||
Line 467:
<pre style="width: 75%; height: 10pc; overflow-y: scroll;">const int motor1Pin1 = 10;
const int motor1Pin2 = 11;
▲const int enablem1Pin3 = 12;
const int motor2Pin1 = 6;
const int motor2Pin2 = 5;
const int
const int buzzer = 12;
int i = 0;
byte serialA;
void setup() {
Serial.begin(9600);
pinMode(motor1Pin1, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
pinMode(enablem1Pin3, OUTPUT);▼
pinMode(motor2Pin1, OUTPUT);
pinMode(motor2Pin2, OUTPUT);
pinMode(
}
void alarm()
{
for (int i=0; i<2; i++) //alarm will ring for 2 seconds once triggered
{
delay(500);
delay(100);
}
}
void loop() {
Line 499 ⟶ 515:
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
▲ digitalWrite(enablem1Pin3, HIGH);
digitalWrite(enablem2Pin3, HIGH);▼
break;
Line 509 ⟶ 523:
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
digitalWrite(enablem1Pin3, HIGH);▼
▲ digitalWrite(enablem2Pin3, LOW);
break;
Line 519 ⟶ 531:
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
break;
Line 529 ⟶ 539:
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, LOW);
break;
// forward right
case 'I':
Line 540 ⟶ 547:
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
break;
// backward left
Line 551 ⟶ 555:
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
break;
Line 561 ⟶ 563:
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, HIGH);
break;
Line 571:
digitalWrite(motor2Pin1, HIGH);
digitalWrite(motor2Pin2, LOW);
break;
Line 581 ⟶ 579:
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, LOW);
break;
case 'w':
break;
case 'V':
alarm();
break;
▲ }
}
</pre>
{{notice|Need to implement the Speed control using the enable pins on L298N instead of the Input Pins}}
[[File:Arduino Bluetooth RC Car bb.png|thumb|right|Arduino Bluetooth RC Car]]
|