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
Devices
Motor
DC
Two DC Motors 60 Percent.c
1
/*
2
Two DC Motors 60 Percent.c
3
4
Drive a pair of DC motors at 6/10 of full speed.
5
6
http://learn.parallax.com/propeller-c-tutorials
7
*/
8
9
#include "simpletools.h"
10
11
int
main
()
12
{
13
// Keep pins low if unused.
14
set_outputs(5, 2, 0b0000);
15
set_directions(5, 2, 0b1111);
16
17
// Start PWM process. Frequency = 1 kHz -> pulse period = 1 ms.
18
pwm_start(1000);
19
20
// Turn motors counterclockwise for 3 s.
21
pwm_set(3, 0, 600);
22
pwm_set(4, 1, 600);
23
pause(3000);
24
25
// Stop for 1 second.
26
pwm_set(3, 0, 0);
27
pwm_set(4, 1, 0);
28
pause(1000);
29
30
// Turn motors counterclockwise for 3 s.
31
pwm_set(2, 0, 600);
32
pwm_set(5, 1, 600);
33
pause(3000);
34
35
// Stop again
36
pwm_set(2, 0, 0);
37
pwm_set(5, 1, 0);
38
39
// End the PWM process
40
pwm_stop();
41
}
42
main
int main(void)
Definition:
GraphicsTest.c:20
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12