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
|
/*
Copyright (c) 2016 CurlyMo <curlymoo1@gmail.com>
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "wiringx.h"
int main() {
if(wiringXSetup("raspberrypi3", NULL) == -1) {
wiringXGC();
return -1;
}
pinMode(9, PINMODE_OUTPUT);
digitalWrite(9, HIGH);
pinMode(8, PINMODE_OUTPUT);
pinMode(9, PINMODE_INPUT);
while(1) {
printf("Writing to GPIO %d: High\n", 8);
digitalWrite(8, HIGH);
printf("Reading from GPIO %d: %d\n", 9, digitalRead(9));
usleep(100000);
printf("Writing to GPIO %d: Low\n", 8);
digitalWrite(8, LOW);
printf("Reading from GPIO %d: %d\n", 9, digitalRead(9));
usleep(100000);
}
}
|