2019 Botball Training
Week Three
Using the iCreate
Training Schedule
We will meet from 7:00 - 9:30 PM every Friday from January 11 to February 1.
1/11: Introduction to Programming
1/18: Using a Drive Base and More C Programming
1/25: Using the iCreate
2/1: Advanced Topics
Please try to be on time for the training meetings and make sure to bring your own device!
Week Two Recap
We went over:
Using the iCreate
Ground Rules
What is the iCreate?
Important iCreate Functions
Important iCreate Functions
iCreate Documentation
A full list of functions that can be used with the Create can be found here:
http://files.kipr.org/wallaby/wallaby_doc/create_8h.html
The iCreate Documentation can be found here: https://www.adafruit.com/datasheets/create_2_Open_Interface_Spec.pdf
Try moving the Create!
Try moving the Create!
int main()
{
create_connect();
create_drive_direct(200, 200);
msleep(500);
create_drive_direct(-200, -200);
msleep(500);
create_stop();
create_disconnect();
return 0;
}
Move forward at 200 speed for 0.5 seconds.
Move backward at 200 speed for 0.5 seconds.
Turning
Sensors
What are Sensors?
Analog vs. Digital
Sensors
Sensor ports
Sensor Commands
iCreate Exercises
Exercise 1
Your program must:
Getting the bumper sensor for the create:
get_create_lbump()
get_create_rbump()
Remember to run the robot on the ground!
Solution for Exercise 1
int main()
{
create_connect();
int tme = 0;
create_drive_direct(150, 150);
while (!get_create_lbump() && !get_create_rbump()) {
msleep(50); // wait until touch is pressed
tme += 50;
}
create_drive_direct(-150, -150);
msleep(tme);
create_stop();
create_disconnect();
}
Exercise 2
Your program must:
Remember to run the robot on the ground!
Solution for Exercise 2
int main()
{
create_connect();
int i;
for (i = 0; i < 4; i++) {
create_drive_direct(150, 150);
msleep(1000);
create_drive_direct(150, -150);
msleep(600);
}
create_stop();
create_disconnect();
}
Exercise 3
Your program must:
Remember to run the robot on the ground!
Solution for Exercise 3
int main()
{
create_connect();
create_drive_direct(150, 150);
int time_passed = 0;
int conditions_satisfied = 0;
while (!conditions_satisfied) {
if (get_create_lbump() || get_create_rbump()) {
conditions_satisfied = 1;
printf(“Touch Sensor Pressed!\n”);
} else if (time_passed > 5000) {
conditions_satisfied = 1;
printf(“Five Seconds Passed!\n”);
}
time_passed += 20;
msleep(20);
}
create_stop();
create_disconnect();
}
Exercise 4
Menus are a versatile and robust option for selecting different programs to run.
Your program must:
Remember to run the robot on the ground!
Solution for Exercise 4
int main() {
create_connect();
int condition;
while (!a_button() && !b_button() && !c_button()) {
if (a_button()) {
condition = 1;
} else if (b_button()) {
condition = 2;
} else if (c_button()) {
condition = 3;
break;
}
msleep(20);
}
create_drive_direct(150, 150);
int time_passed = 0;
while (
!(condition == 1 && (get_create_lbump() || get_create_rbump())) &&
!(condition == 2 && analog(0) < 1000) &&
!(condition == 3 && time_passed > 5000)) {
time_passed += 20;
msleep(20);
}
create_stop();
create_disconnect();
}
Closing Thoughts
Next week, we will cover advanced topics including game strategy and complex robot movement.
Please leave the robot on the desk with the charger.
Code Solutions are posted at: https://tinyurl.com/botballtraining
More botball functions (old but most are the same):
See you next week!