RC Car
This commit is contained in:
BIN
RC Transmitter&Receiver/3D Models/RC Car/Back Suspension.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Back Suspension.stl
Normal file
Binary file not shown.
BIN
RC Transmitter&Receiver/3D Models/RC Car/Back Top Cover.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Back Top Cover.stl
Normal file
Binary file not shown.
BIN
RC Transmitter&Receiver/3D Models/RC Car/Back Whel Axel x2.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Back Whel Axel x2.stl
Normal file
Binary file not shown.
BIN
RC Transmitter&Receiver/3D Models/RC Car/Back Whel Hub x2.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Back Whel Hub x2.stl
Normal file
Binary file not shown.
BIN
RC Transmitter&Receiver/3D Models/RC Car/Front Suspension x2.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Front Suspension x2.stl
Normal file
Binary file not shown.
BIN
RC Transmitter&Receiver/3D Models/RC Car/Front Top Cover.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Front Top Cover.stl
Normal file
Binary file not shown.
BIN
RC Transmitter&Receiver/3D Models/RC Car/Front Whel Axel.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Front Whel Axel.stl
Normal file
Binary file not shown.
BIN
RC Transmitter&Receiver/3D Models/RC Car/Front Whel Hub x2.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Front Whel Hub x2.stl
Normal file
Binary file not shown.
BIN
RC Transmitter&Receiver/3D Models/RC Car/Main Body.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Main Body.stl
Normal file
Binary file not shown.
BIN
RC Transmitter&Receiver/3D Models/RC Car/Middle Cover.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Middle Cover.stl
Normal file
Binary file not shown.
BIN
RC Transmitter&Receiver/3D Models/RC Car/Motor Top Cover x2.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Motor Top Cover x2.stl
Normal file
Binary file not shown.
BIN
RC Transmitter&Receiver/3D Models/RC Car/Steering Arms.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Steering Arms.stl
Normal file
Binary file not shown.
BIN
RC Transmitter&Receiver/3D Models/RC Car/Steering Hubs.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Steering Hubs.stl
Normal file
Binary file not shown.
BIN
RC Transmitter&Receiver/3D Models/RC Car/Suspension Arm x8.stl
Normal file
BIN
RC Transmitter&Receiver/3D Models/RC Car/Suspension Arm x8.stl
Normal file
Binary file not shown.
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 272 KiB After Width: | Height: | Size: 272 KiB |
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
@@ -20,7 +20,7 @@ struct MyData {
|
||||
MyData data;
|
||||
unsigned long lastRecvTime = 0;
|
||||
|
||||
RF24 radio(8, 7);
|
||||
RF24 radio(7, 8);
|
||||
const uint64_t pipeIn = 0xE8E8F0F0E1LL;
|
||||
|
||||
#define servo_pin 3
|
||||
@@ -28,6 +28,10 @@ const uint64_t pipeIn = 0xE8E8F0F0E1LL;
|
||||
#define motor_forward_pin 5
|
||||
#define motor_backward_pin 6
|
||||
|
||||
#define horn 2
|
||||
#define front_led 10
|
||||
#define back_led 9
|
||||
|
||||
Servo servo;
|
||||
|
||||
void setup() {
|
||||
@@ -35,6 +39,10 @@ void setup() {
|
||||
|
||||
servo.attach(servo_pin);
|
||||
|
||||
pinMode(horn, OUTPUT);
|
||||
pinMode(front_led, OUTPUT);
|
||||
pinMode(back_led, OUTPUT);
|
||||
|
||||
pinMode(motor_forward_pin, OUTPUT);
|
||||
pinMode(motor_backward_pin, OUTPUT);
|
||||
|
||||
@@ -53,32 +61,48 @@ void loop() {
|
||||
while (radio.available()) {
|
||||
radio.read(&data, sizeof(MyData));
|
||||
|
||||
/*Serial.print(data.j1PotX);
|
||||
Serial.print(", ");
|
||||
Serial.print(data.j1PotY);
|
||||
Serial.print(", ");
|
||||
Serial.print(data.j2PotX);
|
||||
Serial.print(", ");
|
||||
Serial.print(data.j2PotY);
|
||||
Serial.print(", ");
|
||||
Serial.print(data.pot1);
|
||||
Serial.print(", ");
|
||||
Serial.print(data.pot2);
|
||||
Serial.print(", ");
|
||||
Serial.print(data.tSwitch1);
|
||||
Serial.print(", ");
|
||||
Serial.print(data.tSwitch2);
|
||||
Serial.print(", ");
|
||||
Serial.print(data.button1);
|
||||
Serial.print(", ");
|
||||
Serial.println(data.button2);*/
|
||||
|
||||
//int angle = min(130, max(45, data.j2PotX - 35));
|
||||
int angle = min(130, max(45, (87 + (data.j2PotX - 127) / 2)));
|
||||
servo.write(angle);
|
||||
|
||||
/*Serial.print("throttle : ");
|
||||
Serial.print(data.throttle);
|
||||
Serial.print(", pot1 : ");
|
||||
Serial.println(data.pot1);
|
||||
Serial.print(", angle : ");
|
||||
Serial.println(angle);*/
|
||||
|
||||
if (data.j1PotY < 100) {
|
||||
digitalWrite(motor_forward_pin, LOW);
|
||||
//digitalWrite(motor_backward_pin, HIGH);
|
||||
//analogWrite(motor_forward_pin, 0);
|
||||
analogWrite(motor_backward_pin, map(data.j1PotY, 100, 0, 180, 255));
|
||||
} else if (data.j1PotY > 150) {
|
||||
//digitalWrite(motor_forward_pin, HIGH);
|
||||
digitalWrite(motor_backward_pin, LOW);
|
||||
analogWrite(motor_forward_pin, map(data.j1PotY, 150, 255, 180, 255));
|
||||
//analogWrite(motor_backward_pin, 0);
|
||||
} else {
|
||||
digitalWrite(motor_forward_pin, LOW);
|
||||
digitalWrite(motor_backward_pin, LOW);
|
||||
}
|
||||
|
||||
digitalWrite(horn, data.button2 == 0 ? HIGH : LOW);
|
||||
|
||||
digitalWrite(front_led, data.tSwitch1 == 1 ? HIGH : LOW);
|
||||
digitalWrite(back_led, data.tSwitch1 == 1 ? HIGH : LOW);
|
||||
|
||||
lastRecvTime = millis();
|
||||
}
|
||||
|
||||
@@ -89,6 +113,9 @@ void loop() {
|
||||
|
||||
digitalWrite(motor_forward_pin, LOW);
|
||||
digitalWrite(motor_backward_pin, LOW);
|
||||
digitalWrite(horn, LOW);
|
||||
digitalWrite(front_led, LOW);
|
||||
digitalWrite(back_led, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user