I asked chatGPT to code a sketch for me to function as a digital speedometer.
It's failing to read the VSS signal from my 98 jeep cherokee XJ (4.0, 3 speed auto), though I'm fairly sure i have the right wire from the harness. (still have yet to do a continuity test*)
everything looks good as far as i can tell, I'm pretty good at arduino coding but I'd like a second set of eyes to make sure I'm correct.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define PULSE_PIN 2 // The pin number where the pulse sensor is connected
#define PULSES_PER_MILE 8000 // The number of pulses per mile for your speedometer sensor
// LCD settings
#define LCD_ADDRESS 0x27
#define LCD_ROWS 2
#define LCD_COLUMNS 16
LiquidCrystal_I2C lcd(LCD_ADDRESS, LCD_ROWS, LCD_COLUMNS);
void setup() {
pinMode(PULSE_PIN, INPUT);
lcd.init();
byte dwn[] = {
B10001,
B01010,
B00100,
B10001,
B01010,
B00100,
B10001,
B01010
};
byte up[] = {
B01010,
B10001,
B00100,
B01010,
B10001,
B00100,
B01010,
B10001
};
byte arrw[] = {
B00100,
B00100,
B00100,
B00100,
B10101,
B10101,
B01110,
B00100
};
lcd.createChar(1, dwn);
lcd.createChar(2, up);
lcd.createChar(3, arrw);
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print((char)1);
lcd.print((char)2);
lcd.print((char)1);
lcd.print(" SKRRRR ");
lcd.print((char)2);
lcd.print((char)1);
lcd.print((char)2);
}
void loop() {
unsigned long start_time = millis();
unsigned long pulse_count = 0;
while (millis() - start_time < 1000) {
if (digitalRead(PULSE_PIN) == HIGH) {
pulse_count++;
}
}
float speed_mph = pulse_count * 3600.0 / PULSES_PER_MILE;
lcd.setCursor(0, 1);
lcd.print("Speed: ");
lcd.print(speed_mph);
lcd.print(" mph ");
delay(1000);
}
Any help is greatly appreciated, apologies for any errors in categorization or forum etiquette this is my first forum post here.
*Update: Did a continuity test, definitely have the right wire.
Update 2:
You know I've had better experiences asking reddit, for help, now that says more about this forum than I could in 1000 words.
That being said, many thanks to groundFungus for actually being helpful with no judgement or grandstanding.