– Forward!

Using the “motor” function, you can make your robot move straight forward.

Open up KISS.

Start a New file.

Write the following code:

int main()

{

motor(0,100);

motor(3,100);

msleep(2000);

ao();

}

Compile it. [note the ‘;’ that ends each statement – don’t forget them – the compiler looks for them!]

Download it. [be sure the CBC is on and connected with a USB cable, and that your computer has installed the USB driver software which comes with KISS-C application]

This will cause the motor connected to port 0 to run at full power (100%): motor(0,100)

and the motor connected to port 3 to run at full power (100%): motor(3,100)

and to wait 2 seconds: sleep(2) [for CBC only] or msleep(2000) [for Link controller or CBC] before turning all the motors off: ao()

After you download it onto your controller it should move forward like the robot in the video below. If you don’t know or can’t remember how to download your program onto your controller click here.

My robot won’t go straight even though I wrote the code exactly right!

[Check for correct polarity of port-to-motor.]

What is KISS-C and where do I get it?

The terms ‘motor’, ‘sleep’, and ‘ao’ are special library ‘functions’ for robots using KISS-C.  They are identified by the'( )’ following their name; to learn more about C functions go to Function.  The ‘sleep’ function is just a ‘while()’ loop, DOING NOTHING but watching the controller clock (check “Looping” for details)

Note that the program has several special notations that are required to compile the program in ‘C’

into a notation that can be executed on the robot’s controller:

  • every C program begins: ” int main() “
  • all statements for the main are enclosed in {   }, called a ‘block’ of statements.  They define the functionality of the main.
  • all simple statements end in’;’

Other problems?

NEXT: Making your robot turn.


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s