Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Tone.h> //download: https://github.com/daniel-centore/arduino-tone-library
- Tone speedtone;
- Tone tachtone;
- Tone fueltone;
- long randNumber;
- long tachPulse;
- void setup()
- {
- tachtone.begin(4); //pin that tach is hooked to(PWM PIN REQUIRED)
- speedtone.begin(11); //pin that speedometer is hooked to(PWM PIN REQUIRED)
- randomSeed(analogRead(0));
- }
- void loop()
- {
- randNumber = random(14400,1 000); // generate random number between 100rpm & 7000rpm
- tachPulse = randNumber/144; // 1 puls per varv
- speedtone.play(100, 0); //frequency, duration(0 usually)
- tachtone.play(tachPulse, 0); //frequency, duration(0 usually)
- delay(1000)
- }
Advertisement
Add Comment
Please, Sign In to add comment