Wednesday, 23 January 2013

Classic Controller + Ardumoto = Kiddie Toy

Today I turned my attention to the list of e-mails that I receive outside the helpdesk about CrossWorks and SolderCore.  With a weekend and a couple of extra days off, you wouldn't believe the amount of stuff that piles up!  It's amazing how many customers can order the wrong thing, or how many can't read the manual, or can't even be bothered to look at the CrossWorks manual and use the helpdesk as an on-line help resource.

With those things put to bed, I turned to a question about the PWM output of the SolderCore when a pin is configured as a digital output. I hooked up a scope to the PWM output of the SolderCore and things actually looked good, pretty much as I expected. I need to test some more tomorrow to confirm things.

To put this to good use, I wrote a small CoreBASIC program that uses a Nintendo Classic Controller to control the left and right tracks of a hastily-constructed robot. From the bottom up, the robot is built from a Polulu chassis and motors, a liquidware LiPo battery pack, a SparkFun Ardumoto, a SolderCore, and a SenseCore with a CoreWii adapter fitted:



Here's the CoreBASIC application to exercise this contraption:

' Call up required drivers.
INSTALL "NINTENDO-CLASSIC-CONTROLLER" AS CONTROLLER
INSTALL "SPARKFUN-ARDUMOTO" AS MOTORS

' Run until I die.

WHILE TRUE

  ' Read vertical positions of both controllers.
  THROTTLE = CONTROLLER.V

 
' Ask left and right motors to follow the joysticks.
  MOTORS.LEFT = THROTTLE(0)
  MOTORS.RIGHT = THROTTLE(1)

WEND

END


Now when you move the left joystick forward or back, the left motor's speed and direction follows. Same for the right motor. When you pop the robot on the floor, you can drive it around just like when you had one for Christmas!

I'll blog a bit more about PWM tomorrow along with controlling the robot with a Nintendo Nunchuk controller, as long as I have some spare time.

No comments:

Post a Comment