From 513a79a1c2172d0b920b1688ead34d5dc485454b Mon Sep 17 00:00:00 2001 From: Alex Thomassen Date: Thu, 20 Sep 2018 09:36:25 +0200 Subject: [PATCH] Update .gitignore, add base sketches --- .gitignore | 2 +- Sketches/.vscode/arduino.json | 4 ++ Sketches/.vscode/c_cpp_properties.json | 16 +++++++ Sketches/sketch_sep13a/sketch_sep13a.ino | 38 ++++++++++++++++ Sketches/sketch_sep20a/.vscode/arduino.json | 4 ++ .../.vscode/c_cpp_properties.json | 16 +++++++ Sketches/sketch_sep20a/sketch_sep20a.ino | 45 +++++++++++++++++++ Sketches/sketch_sep20b/sketch_sep20b.ino | 23 ++++++++++ 8 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 Sketches/.vscode/arduino.json create mode 100644 Sketches/.vscode/c_cpp_properties.json create mode 100644 Sketches/sketch_sep13a/sketch_sep13a.ino create mode 100644 Sketches/sketch_sep20a/.vscode/arduino.json create mode 100644 Sketches/sketch_sep20a/.vscode/c_cpp_properties.json create mode 100644 Sketches/sketch_sep20a/sketch_sep20a.ino create mode 100644 Sketches/sketch_sep20b/sketch_sep20b.ino diff --git a/.gitignore b/.gitignore index f33e1a3..f4a5900 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -'libraries' +libraries \ No newline at end of file diff --git a/Sketches/.vscode/arduino.json b/Sketches/.vscode/arduino.json new file mode 100644 index 0000000..8ad31f8 --- /dev/null +++ b/Sketches/.vscode/arduino.json @@ -0,0 +1,4 @@ +{ + "board": "arduino:avr:uno", + "port": "COM7" +} \ No newline at end of file diff --git a/Sketches/.vscode/c_cpp_properties.json b/Sketches/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..fd99c76 --- /dev/null +++ b/Sketches/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "C:\\Users\\Alex\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\**", + "C:\\Users\\Alex\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.6.21\\**" + ], + "forcedInclude": [ + "C:\\Users\\Alex\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.6.21\\cores\\arduino\\Arduino.h" + ], + "intelliSenseMode": "msvc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/Sketches/sketch_sep13a/sketch_sep13a.ino b/Sketches/sketch_sep13a/sketch_sep13a.ino new file mode 100644 index 0000000..6234b03 --- /dev/null +++ b/Sketches/sketch_sep13a/sketch_sep13a.ino @@ -0,0 +1,38 @@ +/* + Blink + + Turns an LED on for one second, then off for one second, repeatedly. + + Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO + it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to + the correct LED pin independent of which board is used. + If you want to know what pin the on-board LED is connected to on your Arduino + model, check the Technical Specs of your board at: + https://www.arduino.cc/en/Main/Products + + modified 8 May 2014 + by Scott Fitzgerald + modified 2 Sep 2016 + by Arturo Guadalupi + modified 8 Sep 2016 + by Colby Newman + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/Blink +*/ + +// the setup function runs once when you press reset or power the board +void setup() { + // initialize digital pin LED_BUILTIN as an output. + pinMode(LED_BUILTIN, OUTPUT); +} + +// the loop function runs over and over again forever +void loop() { + int rnd = random(100, 5000); + digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) + delay(rnd); // wait for a second + digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW + delay(rnd); // wait for a second +} diff --git a/Sketches/sketch_sep20a/.vscode/arduino.json b/Sketches/sketch_sep20a/.vscode/arduino.json new file mode 100644 index 0000000..353b2e9 --- /dev/null +++ b/Sketches/sketch_sep20a/.vscode/arduino.json @@ -0,0 +1,4 @@ +{ + "port": "COM7", + "board": "arduino:avr:uno" +} \ No newline at end of file diff --git a/Sketches/sketch_sep20a/.vscode/c_cpp_properties.json b/Sketches/sketch_sep20a/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..fd99c76 --- /dev/null +++ b/Sketches/sketch_sep20a/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "C:\\Users\\Alex\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\**", + "C:\\Users\\Alex\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.6.21\\**" + ], + "forcedInclude": [ + "C:\\Users\\Alex\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.6.21\\cores\\arduino\\Arduino.h" + ], + "intelliSenseMode": "msvc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/Sketches/sketch_sep20a/sketch_sep20a.ino b/Sketches/sketch_sep20a/sketch_sep20a.ino new file mode 100644 index 0000000..0968281 --- /dev/null +++ b/Sketches/sketch_sep20a/sketch_sep20a.ino @@ -0,0 +1,45 @@ +/** + * Version 1 + */ +float numOne = 1337; +float numTwo = 256; +float numThree = 512; +float numFour = 1024; + +/** + * Version 2 + */ +float myNumbers[4] = {1337, 256, 512, 1024}; + +void setup() { + Serial.begin(9600); + // Version 1 + float sumOne = numOne + numTwo + numThree + numFour; + float dividedOne = sumOne / 4; + + Serial.print("Version 1: "); + Serial.print(dividedOne); + Serial.println(); + + // Version 2 + // Divide length of array by length of a single float byte, + // to get the "correct count" (how many single `float`s exist in the array) + // of myNumbers in the relevant array. + float listLength = sizeof(myNumbers) / sizeof(float); + float sumTwo = 0; + + for (int i = 0; i < listLength; i++) + { + sumTwo = sumTwo + myNumbers[i]; + } + + float dividedTwo = sumTwo / listLength; + + Serial.print("Version 2: "); + Serial.print((dividedTwo)); + Serial.println(); + + Serial.end(); +} + +void loop() {} diff --git a/Sketches/sketch_sep20b/sketch_sep20b.ino b/Sketches/sketch_sep20b/sketch_sep20b.ino new file mode 100644 index 0000000..ec006ad --- /dev/null +++ b/Sketches/sketch_sep20b/sketch_sep20b.ino @@ -0,0 +1,23 @@ +void prnt(int largest, int smallest) { + Serial.print(largest); + Serial.print(" is larger than "); + Serial.print(smallest); + Serial.println(); +} + +void setup() { + Serial.begin(9600); + + int numOne = 6812; + int numTwo = 3333; + + if (numOne > numTwo) { + prnt(numOne, numTwo); + } else { + prnt(numTwo, numOne); + } + + Serial.end(); +} + +void loop() {} \ No newline at end of file