PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Robots
ActivityBot360
Whiskers Push Bot.c
1
/*
2
Whiskers Push Bot.c
3
4
Push the whiskers to make the ActivityBot back up.
5
6
http://learn.parallax.com/activitybot/whisker-wheel-response
7
*/
8
9
#include "
simpletools.h
"
// Include simpletools header
10
#include "
abdrive360.h
"
// Include abdrive header
11
12
int
main
()
// main function
13
{
14
freqout
(4, 2000, 3000);
// Speaker tone: 2 s, 3 kHz
15
16
while
(1)
17
{
18
// Check whisker states.
19
int
wL =
input
(7);
// Left whisker -> wL variable
20
int
wR =
input
(8);
// Right whisker -> wR variable
21
22
// If whisker pressed, back up
23
if
((wL == 0) || (wR == 0))
// Either whisker detects
24
{
25
drive_speed
(-64, -64);
// Back up
26
}
27
else
// Neither whisker detects
28
{
29
drive_speed
(0, 0);
// Stay still
30
}
31
}
32
}
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,...
Definition:
speed.c:138
freqout
void freqout(int pin, int msTime, int frequency)
Use same cog to send square wave of a certain frequency for a certain amount of time....
Definition:
freqout.c:10
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
main
int main(void)
Definition:
GraphicsTest.c:20
input
int input(int pin)
Set an I/O pin to input and return 1 if pin detects a high signal, or 0 if it detects low.
Definition:
input.c:19
abdrive360.h
This library provides a simple set of functions for making the ActivityBot 360 go certain distances a...
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17