I am a beginner in the field Arduino programming and I have a project that seemed relatively simple on paper, but ...
I use 2 Arduino:
(Uno, which will serve as my transmitter) + Joystick + Rf 433mhz
(Duemilanove to serve as receiver) + Dual H Bridge DC Stepper Motor + 2 Motor
Chassis Tamiya 70108
Duemilanove
a bridge h specifically a:
Dual H Bridge DC Stepper Motor
motorPin1a 3 / / On the first front engine
motorPin1b 4 / / On the first rear engine
speedPin1 9 / / L293D enable pin for the first engine
motorPin2a 5 / / Forward the second-engine
motorPin2b 6 / / Walk back the second-engine
speedPin2 10 / / L293D enable pin for the second-engine
RF 433mhz kit
reception
Connecting
7
UNO
I use a simple joystick 6 pin
The connection:
JoyStickPin1 1 / / analog 1
JoyStickPin2 2 / / 2 analog
RF 433
Transmitter
connection:
6
The codes I try
I tried to make this code but it does not work
Issuer:
//Emetteur
#include <VirtualWire.h>
#define motorPin1a 3 // Marche avant du premier moteur
#define motorPin1b 4 // Marche arrière du premier moteur
#define speedPin1 9 // L293D enable pin pour le premier moteur
#define motorPin2a 5 // Marche avant du deuxième moteur
#define motorPin2b 6 // Marche arrière du deuxième moteur
#define speedPin2 10 // L293D enable pin pour le deuxième moteur
#define JoyStickPin1 1 //analog 1
#define JoyStickPin2 2 //analog 2int Mspeed= 0;
int Mspeed1 = 0;
int Mspeed2 = 0;
uint8_t buf[2];void setup() {
pinMode(motorPin1a, OUTPUT);
pinMode(motorPin1b, OUTPUT);
pinMode(speedPin1, OUTPUT);
pinMode(motorPin2a, OUTPUT);
pinMode(motorPin2b, OUTPUT);
pinMode(speedPin2, OUTPUT);if (Mspeed1 > 0) // donc marche arrière
{
analogWrite(speedPin1, abs(Mspeed1));
digitalWrite(motorPin1a, LOW);
digitalWrite(motorPin1b, HIGH);
}
else { // donc marche avant (ou repos)
analogWrite(speedPin1, abs(Mspeed1));
digitalWrite(motorPin1a, HIGH);
digitalWrite(motorPin1b, LOW);
}if (Mspeed2 > 0) // donc marche arrière
{
analogWrite(speedPin2, abs(Mspeed2));
digitalWrite(motorPin2a, LOW);
digitalWrite(motorPin2b, HIGH);
}
else // donc marche avant (ou repos)
{
analogWrite(speedPin2, abs(Mspeed2));
digitalWrite(motorPin2a, HIGH);
digitalWrite(motorPin2b, LOW);vw_set_tx_pin(6);
vw_setup(2000);
}
}void loop() {
Mspeed1 = (analogRead(JoyStickPin1)-511)/2;
Mspeed1 = Mspeed1 - (analogRead(JoyStickPin2)-511)/2;
if (Mspeed1 > 255) {
Mspeed1 = 255;
}
if (Mspeed1 < -255) {
Mspeed1 = -255;
}Mspeed2 = (analogRead(JoyStickPin1)-511)/2;
Mspeed2 = Mspeed2 + (analogRead(JoyStickPin2)-511)/2;
if (Mspeed2 > 255) {
Mspeed2 = 255;
}
if (Mspeed2 < -255) {
Mspeed2 = -255;
}}
receiver:
//recepteur
#include <VirtualWire.h>
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;void setup() {
Serial.begin(9600);
vw_set_rx_pin(7);
vw_setup(2000);
vw_rx_start();
}void loop() {
if (vw_wait_rx_max(200))
if (vw_get_message(buf, &buflen)) {
analogWrite(3, buf[0]);
analogWrite(11, buf[1]);
}
}
I watched a lot of tutorial but I'm not doing
Could you help me?
thank you