summaryrefslogtreecommitdiff
path: root/sensor.c
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-09-22 22:07:06 +0200
committerErich Eckner <git@eckner.net>2019-09-22 22:07:06 +0200
commit21d397bc2e3c5253647cd5af6c78a56853c7bcee (patch)
treea7c943382cd28006e93df77ae7afbff80f95a796 /sensor.c
parentcc092c11bc221de13e439c5155dd1a880cc3e3c2 (diff)
downloadraspi-sensor-21d397bc2e3c5253647cd5af6c78a56853c7bcee.tar.xz
hardware geht erst mal
Diffstat (limited to 'sensor.c')
-rw-r--r--sensor.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/sensor.c b/sensor.c
new file mode 100644
index 0000000..2c933da
--- /dev/null
+++ b/sensor.c
@@ -0,0 +1,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);
+ }
+}