-
Notifications
You must be signed in to change notification settings - Fork 0
/
engine.c
55 lines (47 loc) · 1.07 KB
/
engine.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* =====================================================================================
*
* Filename: engine.c
*
* Description: Biblioteka do obsługi silników DC w robocie
*
* Version: 1.0
* Created: 22/02/17 14:49:40
* Revision: none
* Compiler: gcc
*
* Author: Kacper Szmigiel (), [email protected]
* Organization: elpire.pl
*
* =====================================================================================
*/
#include "mapping.h"
void engine_init()
{
//regulacja prędkości silników
gpioSetMode(PWM1, PI_OUTPUT);
gpioSetMode(PWM2, PI_OUTPUT);
gpioPWM(PWM1, SPEED1);
gpioPWM(PWM2, SPEED2);
//sterowanie silnikami
gpioSetMode(ENG1, PI_OUTPUT);
gpioSetMode(ENG2, PI_OUTPUT);
gpioSetMode(6, PI_OUTPUT);
gpioSetMode(4, PI_OUTPUT);
}
void forward()
{
gpioWrite(ENG1, 1);
gpioWrite(ENG2, 1);
}
void stop()
{
gpioWrite(ENG1, 0);
gpioWrite(ENG2, 0);
}
void turn_right()
{
gpioWrite(ENG1, 1);
gpioDelay(40000);w
gpioWrite(ENG1, 0);
}