Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses

KittyBot and Polite ActivityBot

Curriculum

  • 1 Section
  • 3 Lessons
  • Lifetime
Expand all sectionsCollapse all sections
  • KittyBot and Polite ActivityBot
    3
    • 1.0
      Programming the KittyBot
    • 1.1
      How KittyBot Works
    • 1.2
      Polite ActivityBot Variation

Polite ActivityBot Variation

Don’t like cats? Or perhaps you just want to try out some different sounds?

The Polite ActivityBot is a variation of the same code base, with different WAV files for the three behaviors. Instead of meowing, purring, and hissing, Polite ActivityBot uses its words to nicely request that you move out of its way.

Download the Polite ActivityBot code

 

So Polite!

The behavior code itself is exactly the same, so if you want an explanation of how Polite ActivityBot works just look back one page to “How KittyBot Works”. The code download above already has the new WAV file names in it, you just need to upload the included WAV files to your sd Card. To check out Polite ActivityBot in action, watch the short video below.

]

/*
  Polite ActivityBot.c

  Version 1.0, 10/31/2013

  https://learn.parallax.com/activitybot

  Requires abdrive version 0.5.5 and wavplayer 0.9 or above

  Drive forward until object detected with PING))) sensor on P8, within 20 cm.
  Stop and play 1st audio response from SD, then recheck for object. If it moved,
  play 2nd audio response and continue. If it did not move, play 3rd audio response,
  rotate left or right at random until clear path is detected, then drive forward.
*/

#include "simpletools.h"                       // Include header files
#include "ping.h"
#include "wavplayer.h"                         // Must be 0.9 or later, 10-31-2013
#include "abdrive.h"                           // Must be 0.5.5 or later, 10-31-2013

int main()                                     // Main function
{
  freqout(4, 2000, 2000);                      // Reset indicator
  drive_setRampStep(10);                       // 10 ticks/sec / 20 ms
 
  int DO = 22, CLK = 23, DI = 24, CS = 25;     // SD I/O pins
  sd_mount(DO, CLK, DI, CS);                   // Mount SD card
  wav_volume(10);                              // Set volume here, 1-10

  while(1)
  {
    drive_ramp(128, 128);                      // Forward 128 ticks/second
    while(ping_cm(8) >= 20) pause(5);          // Drive until object in range
 
    drive_ramp(0, 0);                          // Then stop
    wav_play("excuseme.wav");                  // Play wav file named in string
    pause(4000);                               // Time to speak & let obstacle move
 
    if(ping_cm(8) < 21)                        // If obstacle is still there
    {  
      wav_play("byebye.wav");                  // Play wav file named in string
      pause(1000);                             // Time to speak before moving

      int turn = rand() % 2;                   // Turn in a random direction
      if(turn == 1)                            // If turn is odd (1)
        drive_speed(48, -48);                  // rotate right
      else                                     // else if turn is even (0)
        drive_speed(-48, 48);                  // rotate left
    
      while(ping_cm(8) < 20);                  // Turn till object not in view
    }
    else
    {
      wav_play("thankyou.wav");                // Play wav file named in string
      pause(1000);                             // Time to speak before moving
    }
  }
}

 


Printer-friendly version
How KittyBot Works
Prev

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2026 Parallax Learn • Built with GeneratePress