diff --git a/LeonardoProMicro/AutomatedGearShifter/AutomatedGearShifter.ino b/LeonardoProMicro/AutomatedGearShifter/AutomatedGearShifter.ino index 1e8ea76..281cadd 100644 --- a/LeonardoProMicro/AutomatedGearShifter/AutomatedGearShifter.ino +++ b/LeonardoProMicro/AutomatedGearShifter/AutomatedGearShifter.ino @@ -15,7 +15,7 @@ #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) #define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); -#define PinInSpeed 0 //on board: RXI +#define PinInSpeed 1 //on board: RXI #define ServoSwitch 4 //on board: 4 #define ServoPin 8 //on board: 8 #define BrakingLight 9 //on board: 9 BrakingLight @@ -113,7 +113,7 @@ void setup() { display.display(); delay(500); //INPUT - pinMode(PinInSpeed, INPUT); + pinMode(PinInSpeed, INPUT_PULLUP); pinMode(Btn1, INPUT); //OUTPUT pinMode(PinLED, OUTPUT); @@ -177,10 +177,10 @@ void loop() { prepareTurnOff(); } } -//DIAG -// if (speed > 99 || isinf(speed)) { -// speed = 0; -// } + //DIAG + if (speed > 99 || isinf(speed)) { + speed = 21.37; + } calcGear(); displGear = 9 - currentGear; setPosition(currentGear); @@ -265,10 +265,10 @@ void calcSpeed() { speed_last_2 = speed_last; speed_last = speed; speed = (((2 * Pi) / sigleTimeSpd * ((WheelCircumference) / (Pi)) * ms2kmh)) / MagnetsCnt; - if (((speed_last_3 * 1.5) > speed) && speed > 10.0 && speedTrend > 0) { //zabezpieczenie przed losowymi sygnałami magesu - speed = speed_last_3; - - } + // diag + // if (((speed_last_3 * 1.5) > speed) && speed > 10.0 && speedTrend > 0) { //zabezpieczenie przed losowymi sygnałami magesu + // speed = speed_last_3; + // } // speed = (speed + speed_last)/2; // totalDist = totalDist + 1; }