PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
Namespace List
Class List
File List
Examples
Build System
File List
File Members
propsideworkspace
Learn
Examples
ActivityBot
Roaming with Whiskers.c
1
/*
2
Roaming with Whiskers.c
3
4
Go forward until object detected by whisker(s). Then, back up, turn
5
and go a new direction.
6
7
http://learn.parallax.com/activitybot/roaming-whiskers
8
*/
9
10
#include "simpletools.h"
// Include simpletools library
11
#include "
abdrive.h
"
// Include abdrive library
12
13
int
main
()
// main function
14
{
15
freqout(4, 2000, 3000);
// Speaker tone: 2 s, 3 kHz
16
17
while
(1)
// Main loop
18
{
19
// Go forward for 1/50th of a second.
20
drive_speed
(100, 100);
// Go forward
21
22
// Check whisker states.
23
int
wL = input(7);
// Left whisker -> wL variable
24
int
wR = input(8);
// Right whisker -> wR variable
25
26
// If whisker(s) pressed, avoid obstacle.
27
if
(wR == 0)
// Just right whisker
28
{
29
drive_speed
(-100, -100);
// Back up 0.5 seconds
30
pause(500);
31
drive_speed
(-100, 100);
// Turn left 0.22 seconds
32
pause(220);
33
}
34
else
if
(wL == 0)
// Just left whisker
35
{
36
drive_speed
(-100, -100);
// Back up 0.5 seconds
37
pause(500);
38
drive_speed
(100, -100);
// Turn right 0.25 seconds
39
pause(220);
40
}
41
}
42
}
abdrive.h
This library takes care of encoder monitoring and servo signalling, and provides a simple set of func...
main
int main(void)
Definition:
GraphicsTest.c:20
drive_speed
void drive_speed(int left, int right)
Set wheel speeds in encoder ticks per second. An encoder tick is 1/64th of a revolution, and makes causes the wheel to roll 3.25 mm.
Definition:
abdrive.c:417
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12