Merge remote-tracking branch 'origin/main'

This commit is contained in:
Matt McWilliams 2023-02-12 15:59:37 -05:00
commit 34b1613778
2 changed files with 36 additions and 6 deletions

View File

@ -142,9 +142,9 @@ void brake (){
} }
/** /**
* Vex = higher voltage that can power the motor and/or the shield as well as the Arduino if wanted * Vex = Higher voltage that can power the motor and/or the shield as well as the Arduino if wanted
* 5V = Must be a clean 5V that can power the Arduino and shield, and if wanted also the motor itself * 5V = Must be a clean 5V that can power the Arduino and shield, and if wanted also the motor itself
* GND = ass always, the ground of everything * GND = Ass always, the ground of everything
* B- = Connection of the first motor or first winding of the stepper motor * B- = Connection of the first motor or first winding of the stepper motor
* B+ = Connection of the first motor or first winding of the stepper motor * B+ = Connection of the first motor or first winding of the stepper motor
* A- = Connection of the second motor or second winding of the stepper motor * A- = Connection of the second motor or second winding of the stepper motor

View File

@ -1,11 +1,15 @@
/** /**
* Arduino Nano * Arduino Nano (Old Bootloader?)
* L298N * L298N
**/ **/
#include <SoftwareSerial.h> #include <SoftwareSerial.h>
/**
* CONSTANTS
**/
#define Fpos 9 #define Fpos 9
#define Fneg 10 #define Fneg 10
@ -18,9 +22,17 @@
#define Fbutton 3 #define Fbutton 3
#define Bbutton 4 #define Bbutton 4
const frameTime = 40; //ms
const frameSpeed = 255;
/**
* STATE
**/
const int Buttons[2] = {Fbutton, Bbutton}; const int Buttons[2] = {Fbutton, Bbutton};
volatile int ButtonState[4] = {1, 1}; volatile int ButtonState[4] = {1, 1};
volatile long ButtonTime[4] = {0, 0}; volatile long ButtonTime[4] = {0, 0};
volatile long buttontime = 0;
const int Fmotor = 0; const int Fmotor = 0;
const int Bmotor = 1; const int Bmotor = 1;
@ -31,15 +43,29 @@ volatile int Bspeed = 255;
volatile boolean Frunning = false; volatile boolean Frunning = false;
volatile boolean Brunning = false; volatile boolean Brunning = false;
voilatile long timer = 0;
/**
* SERIAL
**/
volatile char cmdChar = 'z'; volatile char cmdChar = 'z';
const char Fcmd = 'D'; const char Fcmd = 'D';
const char Bcmd = 'E'; const char Bcmd = 'E';
const int serialDelay = 5;
SoftwareSerial softSerial (Fsignal, Bsignal); SoftwareSerial softSerial (Fsignal, Bsignal);
void setup() { void setup() {
Serial.begin(57600); Serial.begin(57600);
softSerialmy.begin(9600); Serial.flush();
Serial.setTimeout(serialDelay);
softSerial.begin(9600);
softSerial.flush();
softSerial.setTimeout(serialDelay);
pinMode(Fpos, OUTPUT); pinMode(Fpos, OUTPUT);
pinMode(Fneg, OUTPUT); pinMode(Fneg, OUTPUT);
pinMode(Bpos, OUTPUT); pinMode(Bpos, OUTPUT);
@ -194,10 +220,14 @@ void btn (int index) {
if (val != ButtonState[index]) { if (val != ButtonState[index]) {
if (val == LOW) { // pressed if (val == LOW) { // pressed
ButtonTime[index] = millis(); ButtonTime[index] = millis();
button_start(index, buttontime);
} else if (val == HIGH) { // not pressed } else if (val == HIGH) { // not pressed
buttontime = millis() - ButtonTime[index]; buttontime = millis() - ButtonTime[index];
button_end(index, buttontime); button_end(index, buttontime);
} }
}
if (val == LOW) {
} }
ButtonState[index] = val; ButtonState[index] = val;
} }
@ -220,9 +250,9 @@ void button_end (int index, long buttontime) {
} }
/** /**
* Vex = higher voltage that can power the motor and/or the shield as well as the Arduino if wanted * Vex = Higher voltage that can power the motor and/or the shield as well as the Arduino if wanted
* 5V = Must be a clean 5V that can power the Arduino and shield, and if wanted also the motor itself * 5V = Must be a clean 5V that can power the Arduino and shield, and if wanted also the motor itself
* GND = ass always, the ground of everything * GND = as always, the ground of everything
* B- = Connection of the first motor or first winding of the stepper motor * B- = Connection of the first motor or first winding of the stepper motor
* B+ = Connection of the first motor or first winding of the stepper motor * B+ = Connection of the first motor or first winding of the stepper motor
* A- = Connection of the second motor or second winding of the stepper motor * A- = Connection of the second motor or second winding of the stepper motor