From aa5399befcbe132130837937d429e537e86e03b5 Mon Sep 17 00:00:00 2001 From: lunarised Date: Tue, 12 Mar 2019 10:10:57 +1300 Subject: [PATCH] init commit --- .gitignore | 1 + Abacus/Abacus.ino | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 3 ++ ftypeTest/ftypeTest.ino | 9 ++++++ 4 files changed, 89 insertions(+) create mode 100644 .gitignore create mode 100644 Abacus/Abacus.ino create mode 100644 README.md create mode 100644 ftypeTest/ftypeTest.ino diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..52369be --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +libraries/ diff --git a/Abacus/Abacus.ino b/Abacus/Abacus.ino new file mode 100644 index 0000000..3b145d2 --- /dev/null +++ b/Abacus/Abacus.ino @@ -0,0 +1,76 @@ +/* + *@author James McKenzie + *@lang C89 Based + *@contact lunarised@outlook.com + */ +int i; +void setup() { + pinMode(10, OUTPUT); + pinMode(11, OUTPUT); + pinMode(12, OUTPUT); + pinMode(13, OUTPUT); + pinMode(0, INPUT_PULLUP); + pinMode(1, INPUT_PULLUP); + i = 0; +} + +void loop() { + checkOverflow(i); + bitCheck(i); + inCheck(); +} +/* + * Checks for button inputs on pins 0 and 1 + */ +void inCheck(){ + if (digitalRead(0)==LOW){ + i++; + delay(250); + } + if (digitalRead(1)==LOW){ + i--; + delay(250); + } +} +/* + * Takes an int and sets leds on and off accordingly + * @param i The current value to be displayed + */ +void bitCheck(int i){ + if (i & 1){ + digitalWrite(13, HIGH); + } + else{ + digitalWrite(13, LOW); + } + if (i & 2){ + digitalWrite(12, HIGH); + } + else{ + digitalWrite(12, LOW); + } + if (i & 4){ + digitalWrite(11, HIGH); + } + else{ + digitalWrite(11, LOW); + } + if (i & 8){ + digitalWrite(10, HIGH); + } + else{ + digitalWrite(10, LOW); + } +} +/* + * Checks to make sure the number displayed doesnt overflow + * @param i The number to check overflow + */ +void checkOverflow(int i){ + if (i == 16){ + i = 0; + } + if (i == -1){ + i = 15; + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..37147b7 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# lunarised's Arduino Learning Repository + +## Here i will store some source code for later use diff --git a/ftypeTest/ftypeTest.ino b/ftypeTest/ftypeTest.ino new file mode 100644 index 0000000..95c2b6e --- /dev/null +++ b/ftypeTest/ftypeTest.ino @@ -0,0 +1,9 @@ +void setup() { + // put your setup code here, to run once: + +} + +void loop() { + // put your main code here, to run repeatedly: + +}