Let's Make Robots! | RobotShop

Wild Thumper Robot Controller: getting started autonomously

I'm a beginner in coding and I'm trying my best to work with the sample code, but now I've come to an impass. Can someone tell me what I'm doing wrong with this? http://pastebin.com/cFscTs6d 

I'm getting the error:

Wild_Thumper_Controller_Prototype.ino: In function 'void I2Cmode()':

Wild_Thumper_Controller_Prototype:357: error: a function-definition is not allowed here before '{' token

Wild_Thumper_Controller_Prototype:386: error: expected `}' at end of input

 

I've probably done something very stupid but that's why I'm posting in the begginers forum.

For reference here's my IOpins and Constants:

#define LmotorA             3  // Left  motor H bridge, input A

#define LmotorB            11  // Left  motor H bridge, input B

#define RmotorA             5  // Right motor H bridge, input A

#define RmotorB             6  // Right motor H bridge, input B

#define RCleft              0  // Digital input 0

#define RCright             1  // Digital input 1

// #define S0                  2  // Servo output 00

// #define S1                  4  // Servo output 01

#define S2                  7  // Servo output 02

#define S3                  8  // Servo output 03

#define S4                  9  // Servo output 04

#define S5                 10  // Servo output 05

#define S6                 12  // Servo output 06

#define Battery             A0  // Analog input 00

#define RmotorC             A6  // Analog input 06

#define LmotorC             A7  // Analog input 07

#define Charger             13  // Low=ON High=OFF

---------------Constants-----------

//=================================== MODE OF COMMUNICATIONS 

#define Cmode                2     // Sets communication mode: 0=RC    1=Serial    2=I2C

#define Brate           115200     // Baud rate for serial communications

//=================================== RC MODE OPTIONS 

#define Mix                  1     // Set to 1 if L/R and F/R signals from RC need to be mixed

#define Leftcenter        1500     // when RC inputs are centered then input should be 1.5mS

#define Rightcenter       1500     // when RC inputs are centered then input should be 1.5mS

#define RCdeadband          35     // inputs do not have to be perfectly centered to stop motors

#define scale               12     // scale factor for RC signal to PWM

//=================================== BATTERY CHARGER SETTINGS 

#define batvolt            487     // This is the nominal battery voltage reading. Peak charge can only occur above this voltage.

#define lowvolt            410     // This is the voltage at which the speed controller goes into recharge mode.

#define chargetimeout   300000     // If the battery voltage does not change in this number of milliseconds then stop charging.

//=================================== H BRIDGE SETTINGS 

#define Leftmaxamps        800     // set overload current for left motor 

#define Rightmaxamps       800     // set overload current for right motor 

#define overloadtime       100     // time in mS before motor is re-enabled after overload occurs

//=================================== SERVO SETTINGS 

#define DServo0           1500     // default position for servo0 on "power up" - 1500uS is center position on most servos

#define DServo1           1500     // default position for servo1 on "power up" - 1500uS is center position on most servos

#define DServo2           1500     // default position for servo2 on "power up" - 1500uS is center position on most servos

#define DServo3           1500     // default position for servo3 on "power up" - 1500uS is center position on most servos

#define DServo4           1500     // default position for servo4 on "power up" - 1500uS is center position on most servos

#define DServo5           1500     // default position for servo5 on "power up" - 1500uS is center position on most servos

#define DServo6           1500     // default position for servo6 on "power up" - 1500uS is center position on most servos



- Dan 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thanks! I knew the void loop() was the problem, but I couldn't understand why. Why am I not able to loop code written in void I2Cmode? Does the code written under that automatically loop? Is void I2Cmode similar to calling a function in Matlab? (possible stupid question)

Thanks! I'll definitely check out that link.

I'm having problems connecting a Ping sensor (HCSR04) ultrasonic sesnor to the WTC.

I tested my code on an uno and it works fine. 
What I'm confused about is how the 3 pin male headers. On an uno, I would connect trigger and echo to two pins and supply the power to the sensor with the 5V output and GND. 

On the WTC, there's 5V (5A) output next to the VBAT said to be used for powering sensors. Does that mean I only need to use the signal pin header and disregard the middle Vcc pin and GND pin? I tried wireing the Vcc's  and GND's together, then tried what i just asked, then tried disregarding the 5V (5A) output.

I hooked up the trigger pin to an oscilliscope and am not seeing the 10us pulse that should be there, only noise.
What am I doing wrong? 

Here's my code:

http://pastebin.com/hZLWjT9e

Thanks

line 374 has an extra ; . That will not cause your US sensor issue. I believe your sensor is not connected properly.

Thanks, Just fixed that. Strange that it compiled with that in there. I agree that isn't causing the issue, thanks alot for taking the time to look through the code birdmun.