-
Notifications
You must be signed in to change notification settings - Fork 0
/
scalextricTester.cpp
40 lines (32 loc) · 1005 Bytes
/
scalextricTester.cpp
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
#include <stdio.h> // Used for printf() statements
#include <wiringPi.h> // Include WiringPi library!
#include <time.h>
#include <unistd.h>
// Pin number declarations. We're using the Broadcom chip pin numbers.
const int pin = 21; // PWM LED - Broadcom pin 18, P1 pin 12
int main(void)
{
// Setup stuff:
wiringPiSetupGpio(); // Initialize wiringPi -- using Broadcom pin numbers
pinMode(pin, INPUT); // Set PWM SENSOR as PWM input
//pullUpDnControl(pin, PUD_UP); // Enable pull-up resistor on button
printf("blinker is running! Press CTRL+C to quit.");
struct timespec start, end;
// Loop (while(1)):
double time;
bool aux;
while(1){
while(aux=!digitalRead(pin)){
printf("aire 0: %d\n",!aux);
usleep(500);
}
//clock_gettime(CLOCK_REALTIME,&start);
while(aux=digitalRead(pin)){
usleep(500);
printf("coche: %d\n",aux);
}
//time=end.tv_sec*1000000000+end.tv_nsec-(start.tv_sec*1000000000+start.tv_nsec);
//printf("time: %lf \n",time);
}
return 0;
}