Hello,
I am a new user of this forum, and I have been playing with Arduino for a while now. I am not an expert in coding and as such I come here for advice and help.
Project:
My project is to build a gear indicator for the FSAE team at my university. The goal is to display numbers for each gear and N for when the car is in neutral.Speed is critical in this application
Hardware:
1 big 7 segment display, soldered to board with 220 resistors to an Arduino Nano.
Inputs:
PWM signal from ECU, Motec M400 auxiliary output. I setup a table that has x axis for gear and each gear as a PWM duty cycle associated with.
Neutral (here comes my question), I have an LED circuit by the dash that has a LED with 12V, the engine has a ground trigger for neutral. Can I drive the LED through the Arduino? will that burn my inputs? Should I use a opto-isolator circuit?
Questions:
- Does my code look correct? Am I using the right functions, correctly?
- How can I sense the LED? Find out if I'm in neutral
- Do I need to worry about noise from the ECU, how do I properly power the Arduino in the car? [Does 12V to 5V USB cigarette adapter work?
I get this error for the character:
"deprecated conversion from string constant to 'char*'"
why is that?
Code:
#include "SevSeg.h"
SevSeg sevseg;
volatile int pwm_value = 0;
volatile int prev_time = 0;
int sensorPin = A0;
int sensorValue = 0;
void setup(){
Serial.begin(115200);
attachInterrupt(0, rising, RISING);
byte numDigits = 1;
byte digitPins[] = {};
byte segmentPins[] = {6, 5, 2, 3, 4, 7, 8, 9};
bool resistorsOnSegments = true;
byte hardwareConfig = COMMON_CATHODE;
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
sevseg.setBrightness(100);
}
void loop(){
sensorValue = analogRead(sensorPin);
if (pwm_value > 10 && pwm_value < 20 ) {
sevseg.setNumber(1);
sevseg.refreshDisplay();
}
else if (pwm_value > 20 && pwm_value < 30 ){
sevseg.setNumber(2);
sevseg.refreshDisplay();
}
else if (pwm_value > 30 && pwm_value < 40 ){
sevseg.setNumber(3);
sevseg.refreshDisplay();
}
else if (sensorValue>0){
sevseg.setChars("n");
sevseg.refreshDisplay();
}
else if (pwm_value > 40 && pwm_value < 50 ){
sevseg.setNumber(4);
sevseg.refreshDisplay();
}
else (pwm_value > 50 && pwm_value < 60 );{
sevseg.setNumber(5);
sevseg.refreshDisplay();}
}
void rising() {
attachInterrupt(0, falling, FALLING);
prev_time = micros();
}
void falling() {
attachInterrupt(0, rising, RISING);
pwm_value = micros()-prev_time;
Serial.println(pwm_value);
}
Thank you very much for any help!
Andrea