Hi all, I have run up against a block and I don’t know how to get around it.
Adrunio Uno board to run a ten light array connected to the cars Throttle Position Sensor, .5volts closed throttle and 4.5 volts full throttle.
I thought I had it figured out but when I hooked it to the car I only get the first 4-5 lights to work.
And can’t figure out how to write in a 5volt normally open switch to turn on a single led for the stop lamp.
I have gotten a simple switch to work for the clutch pedal input, yea I did something myself…
The customer is coming up on his race weekend and I still have a lot to do to the car and don’t want to scrap this project, too much time and money in it now to give up. So I am here to ask the experts for help
int potPin = 0;
int i = 0;
void setup()
{
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop()
{
for (i = 1; i<=10; i++);
digitalWrite(i, LOW);
int val = analogRead(potPin);
int count = map(val, 0, 1023, 0, 10);
for (i = 1; i<=10; i++)
if (i<=count)
{
digitalWrite(i, HIGH);
}
else
{
digitalWrite(i, LOW);
}
const int buttonPin =12;
const int ledPin =11;
int buttonState =0;
pinMode (buttonPin, INPUT);
pinMode (ledPin, OUTPUT);
buttonState= digitalRead(buttonPin);
if (buttonState==LOW)
digitalWrite (ledPin, HIGH);
else
digitalWrite (ledPin,LOW);
}