|
THS
|
Main /
WikiSandboxFeel free to use this page to experiment with the Text Formatting Rules. Just click the "Edit Page" link at the bottom of the page.
Defining New StylesYou can use WikiStyles to change the format of text in many ways.
Now I'll use it to create a warning message. Be careful when naming new wiki pages!
code inserts // Include the Command Module API
#include "create.h"
// Pointer to the cr8_t struct
cr8_t *cr8;
// Main function
int main(void)
{
cr8 = cr8_alloc();
// Initialize the Create and Command Module
cr8_init(cr8);
//Update cr8
cr8_update(cr8);
while(1)
{
cr8_set_leds(0,1,0,0);
// Drive forward without hitting wall
while (cr8->wall_range < 120 && cr8->wall_range > 4)
{
cr8_set_leds(1,1,0,0);
// Set the linear and angular speed of the Create to 200mm/s linear and 0 mr/s angular.
cr8_set_speed(200, 0);
//Update again
cr8_update(cr8);
cr8_delay(15);
}
if (cr8->wall_range < 4)
{
cr8_set_speed(0,0); //stop
cr8_set_leds(0,0,0,0);
// cr8_beep_short(); //beep and
cr8_set_speed(50, -70); //turn right if wall seems too far away
}
else if (cr8->wall_range > 120)
{
cr8_set_leds(1,0,0,0);
//cr8_beep_long(); //beep and
cr8_set_speed(60, 70); //turn left if wall seems too close
}
cr8_update(cr8);
cr8_delay(50);
cr8_set_speed(0,0);
//cr8_beep_short();
}
cr8_free(cr8);
return 0;
}
Defining New StylesYou can use WikiStyles to change the format of text in many ways.
Now I'll use it to create a warning message. Be careful when naming new wiki pages! |
|||||||||||||||||||