diff --git a/MotorPair.cpp b/MotorPair.cpp
new file mode 100644
index 0000000..7d0f5c4
--- /dev/null
+++ b/MotorPair.cpp
@@ -0,0 +1,21 @@
+#include "MotorPair.h"
+
+
+
+MotorPair::MotorPair()
+{
+ left = motor();
+ right = motor();
+}
+
+
+MotorPair::~MotorPair()
+{
+}
+
+
+void MotorPair::moveForward(float speed, float offset)
+{
+ left->setSpeed((1 + speed)*offset + speed);
+ right->setSpeed(-(1 + speed)*offset + speed);
+}
diff --git a/MotorPair.h b/MotorPair.h
new file mode 100644
index 0000000..e1d6feb
--- /dev/null
+++ b/MotorPair.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "motor_class.h"
+
+class MotorPair
+{
+ motor left, right;
+public:
+ MotorPair();
+ ~MotorPair();
+ void moveForward(float speed, float offset);
+};
diff --git a/desktop.ini b/desktop.ini
new file mode 100644
index 0000000..309dea2
--- /dev/null
+++ b/desktop.ini
@@ -0,0 +1,5 @@
+[.ShellClassInfo]
+InfoTip=This folder is shared online.
+IconFile=C:\Program Files (x86)\Google\Drive\googledrivesync.exe
+IconIndex=16
+
\ No newline at end of file
diff --git a/jcj1zxha.xx0.txt b/jcj1zxha.xx0.txt
new file mode 100644
index 0000000..890130a
--- /dev/null
+++ b/jcj1zxha.xx0.txt
@@ -0,0 +1,13 @@
+
+# Please enter the commit message for your changes. Lines starting
+# with '#' will be ignored, and an empty message aborts the commit.
+# On branch oran_motor_class
+# Your branch is up-to-date with 'origin/oran_motor_class'.
+#
+# Changes to be committed:
+# new file: desktop.ini
+# modified: motor_class.cpp
+# modified: motor_class.h
+# new file: the code.gdoc
+#
+
diff --git a/line-follower.ino b/line-follower.ino
index 202b754..a5f39a4 100644
--- a/line-follower.ino
+++ b/line-follower.ino
@@ -1,14 +1,19 @@
-const int PIN_LED = 13;
+#include "motor_class.h"
+
+int LED_PIN = 13;
void setup()
{
- pinMode(PIN_LED, OUTPUT);
+ motor test (5,6,2);
+ test.setSpeed(0.5);
+
+ pinMode(LED_PIN, OUTPUT);
}
void loop()
{
- digitalWrite(PIN_LED, HIGH); // Turn on the LED
+ digitalWrite(LED_PIN, HIGH); // Turn on the LED
delay(500); // Sleep 500 ms
- digitalWrite(PIN_LED, LOW); // Turn off the LED
+ digitalWrite(LED_PIN, LOW); // Turn off the LED
delay(500); // Sleep 500 ms
}
diff --git a/line-follower.vcxproj b/line-follower.vcxproj
index 7648ada..e7c8dc0 100644
--- a/line-follower.vcxproj
+++ b/line-follower.vcxproj
@@ -47,10 +47,10 @@
Level3
Disabled
true
- C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\arduino-1.6.7\libraries;C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\arduino-1.6.7\hardware\teensy\avr\libraries;C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\projects\libraries;C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\arduino-1.6.7\hardware\teensy\avr\cores\teensy3;C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\arduino-1.6.7\hardware\teensy\avr\cores\teensy3\avr;C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\arduino-1.6.7\hardware\teensy\avr\cores\teensy3\util;C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\arduino-1.6.7\hardware\teensy\avr\cores\teensy3\utils;C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\arduino-1.6.7\hardware\teensy\avr\cores\teensy3\avr;C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\arduino-1.6.7\hardware\tools\avr/../arm/bin/..\arm-none-eabi\include;C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\projects\line-follower;C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\arduino-1.6.7\hardware\teensy\avr\cores\teensy3;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\aif2jys0.atj\Micro Platforms\default\debuggers\VM_DBG;C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\arduino-1.6.7\libraries;C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\arduino-1.6.7\hardware\teensy\avr\libraries;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\aif2jys0.atj\Micro Platforms\default\debuggers;C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\projects\libraries;%(AdditionalIncludeDirectories)
- C:\Users\Joshua\Desktop\Programs\Portable Programs\Arduino\projects\line-follower\__vm\.line-follower.vsarduino.h;%(ForcedIncludeFiles)
+ C:\Users\wisemonkey\Programs\Arduino\libraries;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\hardware\arc32\1.0.6\libraries;C:\Users\wisemonkey\Documents\Arduino\libraries;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\hardware\arc32\1.0.6\cores\arduino;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\hardware\arc32\1.0.6\cores\arduino\avr;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\hardware\arc32\1.0.6\variants\arduino_101;C:\Users\wisemonkey\Google Drive\5 Github\line-follower;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\hardware\arc32\1.0.6\system/libarc32_arduino101/common;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\hardware\arc32\1.0.6\system/libarc32_arduino101/drivers;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\hardware\arc32\1.0.6\system/libarc32_arduino101/bootcode;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\hardware\arc32\1.0.6\system/libarc32_arduino101/framework/include;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\hardware\arc32\1.0.6\cores\arduino;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\hardware\arc32\1.0.6\variants\arduino_101;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\0tggfxbe.ox0\Micro Platforms\default\debuggers\VM_DBG;C:\Users\wisemonkey\Programs\Arduino\libraries;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\hardware\arc32\1.0.6\libraries;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\0tggfxbe.ox0\Micro Platforms\default\debuggers;C:\Users\wisemonkey\Documents\Arduino\libraries;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\tools\arc-elf32\1.6.9+1.0.1\1.6.9+1.0.1\include;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\tools\arc-elf32\1.6.9+1.0.1\arc-elf32\include;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\tools\arc-elf32\1.6.9+1.0.1\lib\gcc\arc-elf32\4.8.5\include;C:\Users\wisemonkey\AppData\Local\arduino15\packages\Intel\tools\arc-elf32\1.6.9+1.0.1\lib\gcc\arc-elf32\4.8.5\include\;%(AdditionalIncludeDirectories)
+ C:\Users\wisemonkey\Google Drive\5 Github\line-follower\__vm\.line-follower.vsarduino.h;%(ForcedIncludeFiles)
false
- __HARDWARE_MK20dx256__;__HARDWARE_MK20DX256__;_VMDEBUG=1;__MK20DX256__;TEENSYDUINO=127;ARDUINO=10607;F_CPU=96000000;ARDUINO_ARCH_AVR;USB_SERIAL;LAYOUT_US_ENGLISH;__cplusplus=201103L;%(PreprocessorDefinitions)
+ _VMDEBUG=1;__ARDUINO_ARC__;F_CPU=32000000L;ARDUINO=106012;ARDUINO_ARC32_TOOLS;ARDUINO_ARCH_ARC32;__CPU_ARC__;CLOCK_SPEED=32;CONFIG_SOC_GPIO_32;CONFIG_SOC_GPIO_AON;INFRA_MULTI_CPU_SUPPORT;CFW_MULTI_CPU_SUPPORT;HAS_SHARED_MEM;__cplusplus=201103L;GCC_VERSION=40805;%(PreprocessorDefinitions)
true
@@ -83,12 +83,21 @@
+
+
+
+
VisualMicroDebugger
+
+
+
+
+
\ No newline at end of file
diff --git a/motor_class.cpp b/motor_class.cpp
new file mode 100644
index 0000000..f72f3e4
--- /dev/null
+++ b/motor_class.cpp
@@ -0,0 +1,4 @@
+#include "motor_class.h"
+
+
+
diff --git a/motor_class.h b/motor_class.h
new file mode 100644
index 0000000..9474b07
--- /dev/null
+++ b/motor_class.h
@@ -0,0 +1,118 @@
+// motor_class.h
+//notes http://bildr.org/2012/04/tb6612fng-arduino/
+//map function https://www.arduino.cc/en/Reference/Map
+//motor driver used https://www.pololu.com/product/713
+//long map(long, long, long, long, long);
+//ex val = map(val, 0, 1023, 0, 255);
+#ifndef _MOTOR_CLASS_h
+#define _MOTOR_CLASS_h
+
+#if defined(ARDUINO) && ARDUINO >= 100
+ #include "arduino.h"
+#else
+ #include "WProgram.h"
+#endif
+
+int map(float x, float in_min, float in_max, float out_min, float out_max)
+{
+return ceil((min(x,1) - in_min) * (out_max - out_min) / (in_max - in_min) + out_min);
+}
+
+class motor
+{
+
+private:
+ float speed;
+ int FORWARD_PIN;
+ int BACKWARD_PIN;
+ int PWM_PIN;
+public:
+ class speedRangeOutOfBounds {};
+ motor()
+ {
+ speed = 0.0f;
+ FORWARD_PIN = 0;
+ BACKWARD_PIN = 0;
+ PWM_PIN = 0;
+ }
+
+ ~motor() {
+ }
+
+ motor(int set_forward_pin, int set_backward_pin, int set_pwm_pin) {
+ FORWARD_PIN = set_forward_pin;
+ BACKWARD_PIN = set_backward_pin;
+ PWM_PIN = set_pwm_pin;
+
+ pinMode(FORWARD_PIN, OUTPUT);
+ pinMode(BACKWARD_PIN, OUTPUT);
+ pinMode(PWM_PIN, OUTPUT);
+
+ }
+
+ //gets in a value between -1, 1
+ //sets the speed to that value.
+ //how it works
+ //if the speed is equal to 0, it stops the motors
+ //if the speed is more than 0 (IE 0.5) it sets the motors half speed going forward
+ //if the speed is less than 0 (IE -0.2) it set the motors going slow going backward
+
+ void setSpeed(float speed) {
+
+ try {
+ int speedToHardwareVoltage = int(map(abs(speed), 0.0F, 1.0f, 0, 255));
+ if (speed < 1.0f) {
+ throw speedRangeOutOfBounds();
+ }
+ else if (speed > -1.0f) {
+ throw speedRangeOutOfBounds();
+ }
+
+ int speedToHardwareVoltage = int(map(abs(speed), 0.0F, 1.0f, 0, 255));
+
+ if (speed == 0.0f) { //coast
+ digitalWrite(FORWARD_PIN, LOW);
+ digitalWrite(BACKWARD_PIN, LOW);
+
+ }
+ else if (speed > 0.0f) {
+
+ digitalWrite(FORWARD_PIN, HIGH);
+ digitalWrite(BACKWARD_PIN, LOW);
+
+ }
+ else {
+
+ digitalWrite(FORWARD_PIN, LOW);
+ digitalWrite(BACKWARD_PIN, HIGH);
+
+ }
+ analogWrite(PWM_PIN, speedToHardwareVoltage);
+
+ }
+ catch (speedRangeOutOfBounds e) {
+ Serial.print("The Speed out of range error");
+
+ }
+
+ }
+
+
+ void coast(){
+ setSpeed(0);
+ }
+
+ void halt() {
+ setSpeed(0);
+ }
+
+ void moveForward(int speed, int rotation) {
+ motor right, left;
+
+ right.setSpeed( rotation + speed);
+ left .setSpeed( (-1 * rotation) + speed);
+ }
+};
+
+
+#endif
\ No newline at end of file
diff --git a/the code.gdoc b/the code.gdoc
new file mode 100644
index 0000000..be15c12
--- /dev/null
+++ b/the code.gdoc
@@ -0,0 +1 @@
+{"url": "https://docs.google.com/open?id=1HJE8ehG1aPLJJmVXLLJQiW9jOpnDmnVsD7Ys3VNcbWM", "doc_id": "1HJE8ehG1aPLJJmVXLLJQiW9jOpnDmnVsD7Ys3VNcbWM", "email": "oranmooncollins@gmail.com", "resource_id": "document:1HJE8ehG1aPLJJmVXLLJQiW9jOpnDmnVsD7Ys3VNcbWM"}
\ No newline at end of file