diff --git a/circit.jpg b/circit.jpg index 095f63e..a37b46a 100644 Binary files a/circit.jpg and b/circit.jpg differ diff --git a/relay-dpdt-motor.brd b/relay-dpdt-motor.brd index f8373db..5a9eb59 100644 --- a/relay-dpdt-motor.brd +++ b/relay-dpdt-motor.brd @@ -483,7 +483,7 @@ design rules under a new name. - + @@ -498,51 +498,54 @@ design rules under a new name. - + - - + + - - - - - - + + + + + - - - - - - - - - - + + + + + + + + + + + + + + - - + + @@ -568,20 +571,25 @@ design rules under a new name. - - - - - - + + - + + + + + + + + + + diff --git a/relay-dpdt-motor.sch b/relay-dpdt-motor.sch index 8605211..2893eb4 100644 --- a/relay-dpdt-motor.sch +++ b/relay-dpdt-motor.sch @@ -2690,13 +2690,14 @@ type 0309, grid 2.5 mm - + + - - + + - - + + @@ -2705,23 +2706,23 @@ type 0309, grid 2.5 mm - + - - + + - + - + @@ -2740,12 +2741,6 @@ type 0309, grid 2.5 mm - - - - - + + + + @@ -2780,9 +2780,9 @@ type 0309, grid 2.5 mm - + - + @@ -2795,26 +2795,26 @@ type 0309, grid 2.5 mm - - - + + + - + - - - + + + - - + + - - + + @@ -2831,13 +2831,6 @@ type 0309, grid 2.5 mm - - - - - - - @@ -2852,6 +2845,13 @@ type 0309, grid 2.5 mm + + + + + + + diff --git a/wiperMotorPlatform.ino b/wiperMotorPlatform.ino index 70523bf..074ab3e 100644 --- a/wiperMotorPlatform.ino +++ b/wiperMotorPlatform.ino @@ -6,31 +6,31 @@ #define DEBUG 1 -byte addresses[][7] = {"ampBot","ampCtl"}; +byte addresses[][7] = {"ampBot", "ampCtl"}; typedef enum { role_ping_out = 1, role_pong_back } role_e; // The various roles supported by this sketch -role_e role ; +role_e role ; /** -* Create a data structure for transmitting and receiving data -* This allows many variables to be easily sent and received in a single transmission -* See http://www.cplusplus.com/doc/tutorial/structures/ + Create a data structure for transmitting and receiving data + This allows many variables to be easily sent and received in a single transmission + See http://www.cplusplus.com/doc/tutorial/structures/ */ -struct dataStruct{ +struct dataStruct { unsigned long _micros; int xin; int yin; -}myData; +} myData; -RF24 radio(9,8); //also miso/mosi at 11/12/13 +RF24 radio(9, 8); //also miso/mosi at 11/12/13 #define role_pin 2 /////// remote ///////////// #define AX_pin A0 #define AY_pin A1 ///////// motor ///////////// int inApin[2] = {A3, 6}; // INA: Clockwise input -//had to change inBpin from the default 8,9 +//had to change inBpin from the default 8,9 //beacuse of conflict with NRF24 wiring // on the nano side :/ int inBpin[2] = {7, 10}; // INB: Counter-clockwise input int pwmpin[2] = {3, 5}; // PWM input @@ -40,7 +40,7 @@ int leftMotorSpeed, rightMotorSpeed; void setup() { Serial.begin(115200); - radio.begin(); + radio.begin(); pinMode(role_pin, INPUT); digitalWrite(role_pin, HIGH); @@ -52,8 +52,8 @@ void setup() { radio.openWritingPipe(addresses[1]); radio.openReadingPipe(1, addresses[0]); radio.startListening(); - - if(DEBUG) Serial << "im a bot!" << endl; + + if (DEBUG) Serial << "im a bot!" << endl; } else { role = role_ping_out; @@ -61,59 +61,61 @@ void setup() { radio.openReadingPipe(1, addresses[1]); radio.stopListening(); - if(DEBUG) Serial << "im a controller!" << endl; + if (DEBUG) Serial << "im a controller!" << endl; } - if(role==role_pong_back) + if (role == role_pong_back) { - // Initialize motor pins as outputs - for (int i = 0; i < 2; i++) - { - pinMode(inApin[i], OUTPUT); - pinMode(inBpin[i], OUTPUT); - pinMode(pwmpin[i], OUTPUT); - } - // Initialize braked - for (int i = 0; i < 2; i++) - { - digitalWrite(inApin[i], LOW); - digitalWrite(inBpin[i], LOW); - } - }else if(role == role_ping_out){ - pinMode(AX_pin, INPUT); - pinMode(AY_pin, INPUT); + // Initialize motor pins as outputs + for (int i = 0; i < 2; i++) + { + pinMode(inApin[i], OUTPUT); + pinMode(inBpin[i], OUTPUT); + pinMode(pwmpin[i], OUTPUT); } + // Initialize braked + for (int i = 0; i < 2; i++) + { + digitalWrite(inApin[i], LOW); + digitalWrite(inBpin[i], LOW); + } + } else if (role == role_ping_out) { + pinMode(AX_pin, INPUT); + pinMode(AY_pin, INPUT); + } } void loop() { -/****************** Ping Out Role ***************************/ + /****************** Ping Out Role ***************************/ if (role == role_ping_out) { - + myData.xin = analogRead(AX_pin); - if(myData.xin == 517){ myData.xin = 518;} //terrible hack. + if (myData.xin == 517) { + myData.xin = 518; //terrible hack. + } myData.yin = analogRead(AY_pin); bool ok = radio.write( &myData, sizeof(myData) ); - if(DEBUG) Serial<<"xin:"<