Diesel fuel lift pump pressure controller

Hi , id like some help ,my goal is to write this code so the sequence is- key on , pump runs for 15sec, then off till it gets signal from a source then linear 12-0v pmw till shut down, I'm sure its a awful, but I've spent days trying to write this code, they'll (the individual pieces of the master sequence) compile separately just fine. its when i try to put them together its a failure. I've watched you tube , consulted the reference page, and stack-Exchange. and no one has built something like this that works and i will happily list this on the project hub after its finished to prevent any one else from asking this

''current code-----error msg 'expected ( before int ''

int ledPin1 = 6;    // LED connected to digital pin 6
int potentiometerPin = A0;
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2;     // the number of the engine pin
const int ledPin = 6;      // the number of the LED pin
const int val potValue = potentiometerValue();
 // variables will change:
   int buttonState = 0;         // variable for reading engine  status

void setup() {
  //function to calculate potentiometer value
  int potentiometerValue();
  int potentiometerValue();
  for int fadeValue = map(potValue, 1023, , 0, 255);   // sets the value (range from 0 to 255):

int val = analogRead(potentiometerPin);
return val;
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);

// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if  engine on . If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
  // turn LED on:
  digitalWrite(ledPin, HIGH);
} else {
  // turn pump off:
  digitalWrite(ledPin, LOW);'
Arduino: 1.8.18 (Windows 10), Board: "Arduino Mini, ATmega328P"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\weldh\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\weldh\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\weldh\Documents\Arduino\libraries -fqbn=arduino:avr:mini:cpu=atmega328 -vid-pid=067B_2303 -ide-version=10818 -build-path C:\Users\weldh\AppData\Local\Temp\arduino_build_644885 -warnings=all -build-cache C:\Users\weldh\AppData\Local\Temp\arduino_cache_810629 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avr-gcc.path=C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.arduinoOTA.path=C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -verbose C:\Users\weldh\Documents\Arduino\sketch_jan08b\sketch_jan08b.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\weldh\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\weldh\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\weldh\Documents\Arduino\libraries -fqbn=arduino:avr:mini:cpu=atmega328 -vid-pid=067B_2303 -ide-version=10818 -build-path C:\Users\weldh\AppData\Local\Temp\arduino_build_644885 -warnings=all -build-cache C:\Users\weldh\AppData\Local\Temp\arduino_cache_810629 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avr-gcc.path=C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.arduinoOTA.path=C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -verbose C:\Users\weldh\Documents\Arduino\sketch_jan08b\sketch_jan08b.ino

Using board 'mini' from platform in folder: C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.4

Using core 'arduino' from platform in folder: C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.4

Detecting libraries used...

"C:\\Users\\weldh\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10818 -DARDUINO_AVR_MINI -DARDUINO_ARCH_AVR "-IC:\\Users\\weldh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.4\\cores\\arduino" "-IC:\\Users\\weldh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.4\\variants\\eightanaloginputs" "C:\\Users\\weldh\\AppData\\Local\\Temp\\arduino_build_644885\\sketch\\sketch_jan08b.ino.cpp" -o nul

Generating function prototypes...

"C:\\Users\\weldh\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10818 -DARDUINO_AVR_MINI -DARDUINO_ARCH_AVR "-IC:\\Users\\weldh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.4\\cores\\arduino" "-IC:\\Users\\weldh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.4\\variants\\eightanaloginputs" "C:\\Users\\weldh\\AppData\\Local\\Temp\\arduino_build_644885\\sketch\\sketch_jan08b.ino.cpp" -o "C:\\Users\\weldh\\AppData\\Local\\Temp\\arduino_build_644885\\preproc\\ctags_target_for_gcc_minus_e.cpp"

"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\weldh\\AppData\\Local\\Temp\\arduino_build_644885\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\\Users\\weldh\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10818 -DARDUINO_AVR_MINI -DARDUINO_ARCH_AVR "-IC:\\Users\\weldh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.4\\cores\\arduino" "-IC:\\Users\\weldh\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.4\\variants\\eightanaloginputs" "C:\\Users\\weldh\\AppData\\Local\\Temp\\arduino_build_644885\\sketch\\sketch_jan08b.ino.cpp" -o "C:\\Users\\weldh\\AppData\\Local\\Temp\\arduino_build_644885\\sketch\\sketch_jan08b.ino.cpp.o"

C:\Users\weldh\Documents\Arduino\sketch_jan08b\sketch_jan08b.ino: In function 'void setup()':

sketch_jan08b:15:5: error: expected '(' before 'int'

 for int fadeValue = map,potValue, 1023, , 0, 255);   // sets the value (range from 0 to 255):

     ^~~

C:\Users\weldh\Documents\Arduino\sketch_jan08b\sketch_jan08b.ino:15:21: warning: invalid conversion from 'long int (*)(long int, long int, long int, long int, long int)' to 'int' [-fpermissive]

 for int fadeValue = map,potValue, 1023, , 0, 255);   // sets the value (range from 0 to 255):

                     ^~~

sketch_jan08b:15:35: error: expected unqualified-id before numeric constant

 for int fadeValue = map,potValue, 1023, , 0, 255);   // sets the value (range from 0 to 255):

                                   ^~~~

sketch_jan08b:15:35: error: expected ';' before numeric constant

sketch_jan08b:15:41: error: expected primary-expression before ',' token

 for int fadeValue = map,potValue, 1023, , 0, 255);   // sets the value (range from 0 to 255):

                                         ^

sketch_jan08b:15:49: error: expected ';' before ')' token

 for int fadeValue = map,potValue, 1023, , 0, 255);   // sets the value (range from 0 to 255):

                                                 ^

C:\Users\weldh\Documents\Arduino\sketch_jan08b\sketch_jan08b.ino:15:9: warning: unused variable 'fadeValue' [-Wunused-variable]

 for int fadeValue = map,potValue, 1023, , 0, 255);   // sets the value (range from 0 to 255):

         ^~~~~~~~~

C:\Users\weldh\Documents\Arduino\sketch_jan08b\sketch_jan08b.ino:15:25: warning: unused variable 'potValue' [-Wunused-variable]

 for int fadeValue = map,potValue, 1023, , 0, 255);   // sets the value (range from 0 to 255):

                         ^~~~~~~~

In file included from C:\Users\weldh\AppData\Local\Temp\arduino_build_644885\sketch\sketch_jan08b.ino.cpp:1:0:

C:\Users\weldh\Documents\Arduino\sketch_jan08b\sketch_jan08b.ino: At global scope:

C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.4\cores\arduino/Arduino.h:44:16: error: expected unqualified-id before numeric constant

 #define OUTPUT 0x1

                ^

C:\Users\weldh\Documents\Arduino\sketch_jan08b\sketch_jan08b.ino:22:1: note: in expansion of macro 'OUTPUT'

 OUTPUT pinMode(ledPin, );

 ^~~~~~

C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.4\cores\arduino/Arduino.h:43:15: error: expected unqualified-id before numeric constant

 #define INPUT 0x0

               ^

C:\Users\weldh\Documents\Arduino\sketch_jan08b\sketch_jan08b.ino:24:1: note: in expansion of macro 'INPUT'

 INPUT pinMode(buttonPin, );

 ^~~~~

C:\Users\weldh\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.4\cores\arduino/Arduino.h:40:14: error: expected unqualified-id before numeric constant

 #define HIGH 0x1

              ^

C:\Users\weldh\Documents\Arduino\sketch_jan08b\sketch_jan08b.ino:30:2: note: in expansion of macro 'HIGH'

  HIGH(buttonState = ) {

  ^~~~

exit status 1

expected '(' before 'int'

setup is a void function.

Is there something wrong with your ( key?

The code you posted is incomplete, and has extraneous characters, like the ' here

The for loop starts badly, and goes downhill
It's hard to tell what the intention was

What language is this?

@shadetreewelder: No disrespect at all, but you are trying to run before you can walk. It looks like you've done very little 'C' programming before. That's fine - we've all been there; everybody starts at the bottom of the learning curve. But I think you'd be better off working through some very basic tutorials first. This project is a bit ambitious for someone who is just starting out.

Curious, what you describe is the exact procedure an automotive "key up" follows for the fuel pump. Are you planning this for a vehicle?

ardino ide

is not a language

Hello
Post the entire sketch to see how we can help.
Have a nice day and enjoy coding in C++.

This doesn't do any harm, but it doesn't do a great deal of . . . anything.

yes, also alot of the code it is scavenged from different places and i must of missed that when i was relabeling it

well i just copied it from the project hub

this is the entire code i even ran it thorugh paste of code , but ill give you a screenshot

image

The highlighted line makes zero sense - that's why the compiler barfs.

Please post code, in code tags, not pictures of code.

Be prepared for further barfs

i think posted the wrong sketch, is it possible to delete this thread and start fresh

i forgot that i had split it in two sketches to conquer separately so here's the part that should complie

[code]
int ledPin1 = 6;    // LED connected to digital pin 6
int potentiometerPin = A0;

void setup()
{
  // nothing happens in setup
}

void loop()
{
  int potValue = potentiometerValue();
  int Value = map(potValue, 1023, , 255); // sets the value (range from 0 to 255):
  delay(30);
  analogWrite(ledPin1, fadeValue);
  );

}
//function to calculate potentiometer value
int potentiometerValue()
{
  int val = analogRead(potentiometerPin);
  return val;
}
[/code]

See that gap between those commas?
Do you know what should be there?
Neither does the compiler.

You've got an extraneous ");" just before the end of loop()

const byte ledPin1 = 6;    // LED connected to digital pin 6
const byte potentiometerPin = A0;

void setup()
{
}

void loop()
{
  int potValue = potentiometerValue();
  int Value = potValue / 4;
  delay(30);
  analogWrite(ledPin1, Value);
}
//function to calculate potentiometer value
int potentiometerValue()
{
  int val = analogRead(potentiometerPin);
  return val;
}

(Uncompiled, untested)

i fixed what you menited but i also have this skecth from somebody else, but it wouldnt complie for nothing and is what i spent half my time "fixing" it , but now it seems to work so i just need to add the engine on check and itll be smooth sailing

[code]
// Arduino fuel pump controller

int pwmPin_A = 3; // output pin supporting PWM
int inPin = 4; // map sensor voltage connected to analog pin 4
int val = 5; // variable to store the read value

void setup()
{

  pinMode(pwmPin_A, OUTPUT); // sets the pin as output
  analogWrite(pwmPin_A, 255); // primes the pump at full power
  delay(2000); // pump runs for 2 seconds 1000= 1 second

}
void loop()
{
  val = analogRead(inPin); // read the input pin




  // Input pin takes voltage from
  // this sensor and converts it to a number between 0 and 1023
  // 0 should equal 0 volts and 1023 should equal 5 volts
  // To get 0-1023 number multiply input volts (v) by 1023 the divide by 5 v*1023/5 Example:2*1023/5=409.2
  // PWM pin converts this to a number between 0 and 255
  // where 0 is 0% duty cycle and 255 is 100% duty cycle


  int val = analogRead(inPin);

  if (val > 400) {
    analogWrite(pwmPin_A, 255); // Pump stays at 100% duty when pressure
    // surpasses specified range. (when map voltage is higher than what you put in the valMap function)

  }

  else if (val < 133) {
    analogWrite(pwmPin_A, 80); // Pump stays at ~31% duty in case vaccum goes below specified range.(downshifting)

  }
  else {
    analogWrite(pwmPin_A, val); //If all the above arguments aren't valid then controller uses the linear function specified earlier.

  }

[/code]

I can't really see the difference between using "val" and "valMap", except that one is about 100us older than the other, and using "valMap" may wrap, because it is a ten bit value, and analogWrite expects an eight bit value

ok i changed it so it wont wrap, would you know where to look to know how to add the engine on condition,its just so its a little more idiot proof ?

Hi, @shadetreewelder
Can you please tell us your electronics, programming, arduino, hardware experience?
How much Arduino C++ code have you written?

Why are you trying to cut and paste code you do not understand in the first place?
How about you start and develop your own code for your project.

If you are new to Arduino, I would suggest the this is way beyond your current ability and need to start with a less ambitious project.

What do you want the potentiometer to do?
How are you going to control your pump?
How are you going to read pressure, as your subject says "pump pressure controller".

From what I read in post#1.

Do you initially want at key ON, the pump to start and pressurize the system?
What does 15secoinds have to do with that?
Shouldn't you be measuring the system pressure and turn OFF the pump when pressure is attained.
If you want some safety factor.
Use a timer to check if pressure is not reached in a certain time to signal a fault.

Then when the device is running and using fuel you want the pump to maintain pressure, using a pump speed control.

This is basically how a modern fuel injected engine starts and runs.

Tom... :grinning: :+1: :coffee: :australia: