UKHeliBob:
You say that it works using analogWrite()
Please post the full code for that version
What exactly is connected to the output pin ?
Which Arduino board are you using ?
void loop() {
analogWrite(6, 127);
}
This is all i need for analogWrite to output a value, but now i'm getting confused. When i was experimenting with a 555 timer, it really was around 2,41Hz per km/h. But now i'm sending the full 980Hz into the speedo, and getting around 120km/h, which is weird. I changed the pin to 9, and i'm getting the same result.
I'm using an Arduino Nano, and i connected the signal input pin to the output of the Arduino. I don't know anything about the inner workings of the speedo, because it's an old speedo and i cant find anything about it on the internet. I only have the pinout.
johnwasser:
It's missing '}' in two places. Perhaps the problem is in the other parts you aren't showing.
20 milliseconds of delay will get you about 50 Hz so about 20 kph?
Did you remember to connect both Ground and Pin 6 to your device?
What do you mean by "base dimming sketch"?
The PWM pins are 490.20 Hz or 976.56 Hz. Shouldn't that give you 203.4 kph or 405.2 kph?
The code on the arduino is fine, since the missing }'s are just from me manually retyping the code since i'm using a different device for programming. I connected all the pins fine from what i can see, since it works on analogWrite. And the base dimming sketch i was talking about is this one.
/*
Fading
This example shows how to fade an LED using the analogWrite() function.
The circuit:
- LED attached from digital pin 9 to ground.
created 1 Nov 2008
by David A. Mellis
modified 30 Aug 2011
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Fading
*/
int ledPin = 6; // LED connected to digital pin 9
void setup() {
// nothing happens in setup
}
void loop() {
// fade in from min to max in increments of 5 points:
for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
// fade out from max to min in increments of 5 points:
for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
}
And regarding the PWM pins, that's now something im thinking about. It really shouldn't output only 120km/h at those frequencies. I kind of wanna try sending 12V as a signal instead of 5, but im worried about breaking the speedometer.