Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- #define MotorA_F 4
- #define MotorA_B 5
- #define MotorB_F 6
- #define MotorB_B 7
- #define ENA 9
- #define ENB 10
- #define tx 3
- #define rx 2
- SoftwareSerial Bluetooth(rx,tx);
- char _read;
- void setup() {
- pinMode(MotorA_F, OUTPUT);
- pinMode(MotorA_B, OUTPUT);
- pinMode(MotorB_F, OUTPUT);
- pinMode(MotorB_B, OUTPUT);
- pinMode(ENA, OUTPUT);
- pinMode(ENB, OUTPUT);
- Bluetooth.begin(9600);
- }
- void loop() {
- // Controlling Speed
- analogWrite(ENA, 255);
- analogWrite(ENB, 255);
- if (Bluetooth.available() > 0) {
- _read = Bluetooth.read();
- if (_read == "F") {
- digitalWrite(MotorA_F, HIGH);
- digitalWrite(MotorA_B, LOW);
- digitalWrite(MotorB_F, HIGH);
- digitalWrite(MotorB_B, LOW);
- } else if (_read == "B") {
- digitalWrite(MotorA_F, LOW);
- digitalWrite(MotorA_B, HIGH);
- digitalWrite(MotorB_F, LOW);
- digitalWrite(MotorB_B, HIGH);
- } else if (_read == "L") {
- digitalWrite(MotorA_F, LOW);
- digitalWrite(MotorA_B, HIGH);
- digitalWrite(MotorB_F, HIGH);
- digitalWrite(MotorB_B, LOW);
- } else if (_read == "R") {
- digitalWrite(MotorA_F, HIGH);
- digitalWrite(MotorA_B, LOW);
- digitalWrite(MotorB_F, LOW);
- digitalWrite(MotorB_B, HIGH);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement