r/ArduinoProjects • • Jun 07 '21

My first project: 4 cylinder LED ‘engine’ with potentiometer ‘throttle’

294 Upvotes

29 comments sorted by

4

u/FewDiscipline9 Jun 08 '21

#include <pitches.h>

int buzzerPin = 11;

void setup() {

pinMode(2, OUTPUT); //Subtract one from pin number for cylinder number

pinMode(3, OUTPUT);

pinMode(4, OUTPUT);

pinMode(5, OUTPUT);

pinMode(buzzerPin, OUTPUT);

}

void loop() {

int x;

int delayTime;

int sensorPin = A0; //Potentiometer

int sensorValue;

sensorValue = analogRead(sensorPin);

x = (sensorValue / 4);

delayTime = (x);

// blink all spark plug LEDs in I4 firing order.

// 1-3-4-2

digitalWrite(2, HIGH);

delay(delayTime);

digitalWrite(2, LOW);

tone(buzzerPin, 100, 10);

digitalWrite(4, HIGH);

delay(delayTime);

digitalWrite(4, LOW);

tone(buzzerPin, 100, 10);

digitalWrite(5, HIGH);

delay(delayTime);

digitalWrite(5, LOW);

tone(buzzerPin, 100, 10);

digitalWrite(3, HIGH);

delay(delayTime);

digitalWrite(3, LOW);

tone(buzzerPin, 100, 10);

}

6

u/andymk3 Jun 07 '21

1-3-4-2, nice.

6

u/FewDiscipline9 Jun 07 '21

Ford man at heart. Had to be Pinto firing order 😁

5

u/JimBean Jun 08 '21

Aircraft engineer here. I came to inspect your work. Well done and here is your certification. *****

We would like to see a V8 model. :)

3

u/JimBean Jun 08 '21

Noice. Add an audio player for some vroom vroom noises. :)

2

u/FewDiscipline9 Jun 08 '21

I've harvested a speaker from an old alarm clock radio, I'm now trying to work out how to make it sound a bit beefier, rather than sounding like a Geiger counter

3

u/Tyrannosaurusblanch Jun 08 '21

If OP posts the code I’m so going to stick the lights parts on my throttle.

2

u/FewDiscipline9 Jun 08 '21

Posted code in comments :)

1

u/Tyrannosaurusblanch Jun 08 '21

Thank you

Vroom vroom

2

u/GALACTON Jun 07 '21

code?

1

u/FewDiscipline9 Jun 08 '21

Posted code in comments below

2

u/ProfessionalMuki Jun 08 '21

Any video or scheme for that circuit?

2

u/FewDiscipline9 Jun 08 '21

Looking to make a schematic diagram, I'm new to all this so I'm wondering what website/software I can use to create said diagrams?

2

u/JimBean Jun 09 '21

A proper circuit diagram with components can be created using Eagle circuit design software. It's free. Expect a steep learning curve.

1

u/ProfessionalMuki Jun 08 '21

I have no idea as well.Did you watch any tutorial or something?

19

u/SmokyOwl Jun 07 '21

Could be nicely used in RC models to light up the exhaust pipes!

2

u/Hookiebookie_ Jun 07 '21

That's awesome, I love it!

2

u/Victor_gpz Jun 07 '21

looks awesome dude

2

u/Papa_Nipples Jun 07 '21

Really cool!! This brought back tons of memories for me as this is very similar to what my first project was. Keep up the good work!

2

u/charlySNM Jun 07 '21

Cool project to start learning!!

2

u/F3L1P3L0D1 Jun 07 '21

Very nice application for the potentiometer. I will definitely try it too ;)

2

u/totorodad Jun 08 '21

Cool beans man. Now sim a v8 and each valve type and piston use a separate color. Maybe throw in a stepper motor to spin with and rpm ratio metric to your led timing. For the next level make that arduino your engine sim and a second arduino be your engine controller.

2

u/Yelagandula_9 Jun 08 '21
  • Chernobyl flashbacks *

2

u/Alarratt Sep 15 '21

Easy there, bud. Pretty sure you're floating the hell outta those valves at the end.