I'm working on a school project where I'm trying to wirelessly control a car/tank.
That is currently being powered/controlled via an Arduino, and that gets input from a PC via USB, serial communication "Serial.begin(9600);". Which in turn the Arduino receives and makes the wheels of the car/tank turn in certain ways, for example:
if (Serial.available()) {
val = Serial.read();// then read the serial value
// If statment to read if serial input is W do Forward
if (val == 'w') {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
}
}
Well this is all the code
//L293D Controler for motors
//Motor A
const int motorPin1 = 5; // Pin 14 of L293
const int motorPin2 = 6; // Pin 10 of L293
//Motor B
const int motorPin3 = 10; // Pin 7 of L293
const int motorPin4 = 9; // Pin 2 of L293
int val;
//This will run only one time.
void setup(){
Serial.begin(9600); // Serial comm begin at 9600bps
//Set pins as outputs
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
//Motor Control - Motor A: motorPin1,motorpin2 & Motor B: motorpin3,motorpin4
}
void loop(){
if (Serial.available()) {
val = Serial.read();// then read the serial value
// Forward
if (val == 'w') {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
} //höger, right
else if (val == 'd') {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
} //back, backward
else if (val == 's') {
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
} //vänster,left
else if (val == 'a') {
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
}
}
//reset becasue serial is not available, stops the car/tank
else{
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
}
}
So, in summary, I'm trying to receive serial to the Arduino wirelessly from a PC by pressing down a key on my Keyboard, I have it working using USB directly into the Arduino, but it's no fun having a kind of RC car stuck to a USB Kable so getting the serial input from the PC->somthing->Arduino, that is what I'm having trouble finding an easy way to do, and get my car/tank wireless.
Anyone have any idées what I should do? My school has an HC-05 FC-114 Bluetooth module, but I'm open to everything? Bluetooth, Wireless transceivers, wifi, anything?
PC-> Wireless thing -> Arduino.
