Home | | Schedule | | Assignments | | Lectures | | Resources
/*******************************************************************************
* Authors: A. Student, B. Student and C. Student
* square.c
* Purpose: A simple iRobot program to walk in a square.
* It also plays a short song at the start, at each corner, and at the end.
* Re-written by kwalsh@cs.holycross.edu, based on original simple.c.
*******************************************************************************/
#include "iRobot.h"
// Notes for start song
// Songs are optional
uint8_t start_notes[] = {60, 62, 64, 65, 67, 69, 71}; // ascending scale
uint8_t start_times[] = { 8, 8, 8, 8, 8, 8, 16}; // eighth, ..., eighth, quarter
uint8_t start_count = 7; // seven notes
// Notes for bump/corner song
uint8_t corner_notes[] = {71, 67}; // B, G
uint8_t corner_times[] = {24, 8}; // three-eighth, one-eighth
uint8_t corner_count = 2; // two notes
// Notes for end song
uint8_t end_notes[] = {71, 69, 67, 65, 64, 62, 60}; // descending scale
uint8_t end_times[] = { 8, 8, 8, 8, 8, 8, 16};
uint8_t end_count = 7; // seven notes
int main(void)
{
// define some songs
// Songs are optional
defineSong(0, start_count, start_notes, start_times);
defineSong(1, corner_count, corner_notes, corner_times);
defineSong(2, end_count, end_notes, end_times);
// start the body if needed
start();
waitForButton(); //Optional
// play the start song
playSong(0); //Optional
// drive then turn, repeat 4 times
for (int count = 0; count < 4; count++) {
straight(1*Meter);
playSong(1); //Optional
turn(90);
}
playSong(2); //Optional
}
Home | | Requirements | | Syllabus | | Assignments | | Lectures
CSCI 131: Techniques of Programming
Last Modified: February 23, 2014
Page Expires: October 12, 2014