0% found this document useful (0 votes)
17 views

#Define MOTOR1A 2

The code defines pin assignments for motors and RF link bits. In setup, the pins are configured as inputs and outputs. In loop, the values of the RF link bits are read and used to control the motors - each combination of bit values results in a different motor control setting. If no bits are high, the motors are stopped.

Uploaded by

Rudy Pena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

#Define MOTOR1A 2

The code defines pin assignments for motors and RF link bits. In setup, the pins are configured as inputs and outputs. In loop, the values of the RF link bits are read and used to control the motors - each combination of bit values results in a different motor control setting. If no bits are high, the motors are stopped.

Uploaded by

Rudy Pena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#define MOTOR1A 2

#define MOTOR1B 3
#define MOTOR2A 4
#define MOTOR2B 5

//RF LINK BITS


#define bit0 9
#define bit1 10
#define bit2 11
#define bit3 12

int val0 = 0; // variable to store the read value


int val1 = 0;
int val2 = 0;
int val3 = 0;
int valAll = 0;
int b0=0;
int b1=0;
int b2=0;
int b3=0;

void setup() {

pinMode(bit0, INPUT);
pinMode(bit1, INPUT);
pinMode(bit2, INPUT);
pinMode(bit3, INPUT);

pinMode(MOTOR1A, OUTPUT);
pinMode(MOTOR1B, OUTPUT);
pinMode(MOTOR2A, OUTPUT);
pinMode(MOTOR2B, OUTPUT);
Serial.begin(9600);

void loop() {

val0 = digitalRead(bit0); // read the input pin


val1 = digitalRead(bit1); // read the input pin
val2 = digitalRead(bit2); // read the input pin
val3 = digitalRead(bit3); // read the input pin

if (val0 ==LOW & val1==LOW & val2==LOW & val3==LOW){


digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
}

if (val0 ==HIGH & val1==LOW & val2==LOW & val3==LOW){


digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
}

if (val0 ==LOW & val1== HIGH & val2==LOW & val3==LOW){


digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
}

if (val0 ==LOW & val1==LOW & val2==HIGH & val3==LOW){


digitalWrite(MOTOR1A, HIGH);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, HIGH);
digitalWrite(MOTOR2B, LOW);
}

if (val0 ==LOW & val1==LOW & val2==LOW & val3==HIGH){


digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, HIGH);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, HIGH);
}

else {
digitalWrite(MOTOR1A, LOW);
digitalWrite(MOTOR1B, LOW);
digitalWrite(MOTOR2A, LOW);
digitalWrite(MOTOR2B, LOW);
}

You might also like