Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
34b1613778
|
@ -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
|
||||
* 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
|
||||
* A- = Connection of the second motor or second winding of the stepper motor
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
|
||||
/**
|
||||
* Arduino Nano
|
||||
* Arduino Nano (Old Bootloader?)
|
||||
* L298N
|
||||
**/
|
||||
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
/**
|
||||
* CONSTANTS
|
||||
**/
|
||||
|
||||
#define Fpos 9
|
||||
#define Fneg 10
|
||||
|
||||
|
@ -18,9 +22,17 @@
|
|||
#define Fbutton 3
|
||||
#define Bbutton 4
|
||||
|
||||
const frameTime = 40; //ms
|
||||
const frameSpeed = 255;
|
||||
|
||||
/**
|
||||
* STATE
|
||||
**/
|
||||
|
||||
const int Buttons[2] = {Fbutton, Bbutton};
|
||||
volatile int ButtonState[4] = {1, 1};
|
||||
volatile long ButtonTime[4] = {0, 0};
|
||||
volatile long buttontime = 0;
|
||||
|
||||
const int Fmotor = 0;
|
||||
const int Bmotor = 1;
|
||||
|
@ -31,15 +43,29 @@ volatile int Bspeed = 255;
|
|||
volatile boolean Frunning = false;
|
||||
volatile boolean Brunning = false;
|
||||
|
||||
voilatile long timer = 0;
|
||||
|
||||
/**
|
||||
* SERIAL
|
||||
**/
|
||||
|
||||
volatile char cmdChar = 'z';
|
||||
const char Fcmd = 'D';
|
||||
const char Bcmd = 'E';
|
||||
|
||||
const int serialDelay = 5;
|
||||
|
||||
SoftwareSerial softSerial (Fsignal, Bsignal);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(57600);
|
||||
softSerialmy.begin(9600);
|
||||
Serial.flush();
|
||||
Serial.setTimeout(serialDelay);
|
||||
|
||||
softSerial.begin(9600);
|
||||
softSerial.flush();
|
||||
softSerial.setTimeout(serialDelay);
|
||||
|
||||
pinMode(Fpos, OUTPUT);
|
||||
pinMode(Fneg, OUTPUT);
|
||||
pinMode(Bpos, OUTPUT);
|
||||
|
@ -194,10 +220,14 @@ void btn (int index) {
|
|||
if (val != ButtonState[index]) {
|
||||
if (val == LOW) { // pressed
|
||||
ButtonTime[index] = millis();
|
||||
button_start(index, buttontime);
|
||||
} else if (val == HIGH) { // not pressed
|
||||
buttontime = millis() - ButtonTime[index];
|
||||
button_end(index, buttontime);
|
||||
}
|
||||
}
|
||||
if (val == LOW) {
|
||||
|
||||
}
|
||||
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
|
||||
* 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
|
||||
* A- = Connection of the second motor or second winding of the stepper motor
|
||||
|
|
Loading…
Reference in New Issue