Newbee needing a little help with a project

greetings i am working kinda on a big project. I am vary green at this so please bare with me. i have made one other project but I wanted to my second to be something i can really use. So hear is what I have I own a carwash and I am working with an arduino mega2560. my end goal would be keep a running total of all the money brought in. I would also like a running total on the time that my pump motors have ran (p.m. maint.) everything at the wash runs off of 24v. I have bought 3 icstation 8 channel board 24v to 3.3v that way i don't have 24v to the arduino I think i have all the hardware I need I also think i have alot of the setup done in the program (I Think) could use some help if anyone is up for the challenge

2 Likes

This is is the programming section of the forum, for specific questions about programming.
If you want help with a commercial product, try the "jobs and consultancy" section of the forum (used to be " gigs and collaborations")

Never on a first date.

3 Likes

you have two semi-independent projects

  1. total of money brought in - a PC accounting package?
  2. monitoring of car wash whuich you can do with an microcontroller board
    I would suggest a ESP32 it is powerful, has plenty of IO and has onboard WiFi and Bluettoth.
    It could maintain a record of the time the pumps have run for and display it on a web page which could be accessed from a PC or a smart phone
1 Like

Hi mbertsch,
welcome to the arduino forum

almost any microcontroller can do that.

I can say my opinion about that if you post a list all the hardware-components including links to datasheets of each component.

Again. If I agree I can only say if you would post your complete sketch You can post code by using this method that adds the code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

I'm sure you don't expect that: nobody here is willing to write down a "general purpose learn it all" tutorial for you
The more specific you can ask the better the support will be.

You are working on an informatic project and what is most needed in an informatic project is information. As a real newcomer you can improve your reputation a lot if you read this

and then follow the recommendations that were given.

best regards Stefan

If you want the program written for your business, you can flag this post and ask a moderator to move it to the paid section.

If you want to work on it yourself and ask for help with specific issues, after researching and attempting them yourself, then you are much more likely to receive help from the community.

thank you everyone for the reply's just to be clear I'm wanting to do it on my own with guidance from all of you guys. I am wanting to learn how to program and the best practices to do so i will post what I have so far fallowing this post and for mor specifically i think i have the "coin counting" figured out but I am asking if there is a better way to do so but to be honest i am completely lost on the timing of the pumps part of it I have done a lot of research on the subject but i have a hard time finding anything close to what I'm doing

// LCD Display
#include <Wire.h>
#include <EEPROM.h>

// Coin Count Pulse Pins
int Bay1CoinPin = 22;
int Bay2CoinPin = 23;
int Bay3CoinPin = 24;
int Bay4CoinPin = 25;
int Bay5CoinPin = 26;
int Bay1CoinCount;
int Bay2CoinCount;
int Bay3CoinCount;
int Bay4CoinCount;
int Bay5CoinCount;
int Bay1CoinPinState;
int Bay2CoinPinState;
int Bay3CoinPinState;
int Bay4CoinPinState;
int Bay5CoinPinState;
int Bay1CoinHit;
int Bay2CoinHit;
int Bay3CoinHit;
int Bay4CoinHit;
int Bay5CoinHit;

// Pump Timer Pins
int Bay1PumpPin = 27;
int Bay2PumpPin = 28;
int Bay3PumpPin = 29;
int Bay4PumpPin = 30;
int Bay5PumpPin = 31;
int PreSoakPumpPin = 32;
int SpotFreePumpPin = 33;
int TireCleanPumpPin = 34;
int FoamBrushPumpPin = 35;

// Pump time
int Bay1PumpTime;
int Bay2PumpTime;
int Bay3PumpTime;
int Bay4PumpTime;
int Bay5PumpTime;
int PreSoakPumpTime;
int SpotFreePumpTime;
int TireCleanPumpTime;
int FoamBrushPumpTime;

// Pump Total time
int Bay1PumpTotalTime;
int Bay2PumpTotalTime;
int Bay3PumpTotalTime;
int Bay4PumpTotalTime;
int Bay5PumpTotalTime;
int PreSoakPumpTotalTime;
int SpotFreePumpTotalTime;
int TireCleanPumpTotalTime;
int FoamBrushPumpTotalTime;

// Led Pins
int Bay1PumpLedPin = 36;
int Bay2PumpLedPin = 37;
int Bay3PumpLedPin = 38;
int Bay4PumpLedPin = 39;
int Bay5PumpLedPin = 40;
int PreSoakPumpLedPin = 41;
int SpotFreePumpLedPin = 42;
int TireCleanPumpLedPin = 43;
int FoamBrushPumpLedPin = 44;

int dt = 1;

void setup() {
  Serial.begin(112500);
  Serial.print("Created: ");
  Serial.print(__TIME__);
  Serial.print(", ");
  Serial.println(__DATE__);
  Serial.println(__FILE__);

  // LCD Display Setup

  // Bay Coin Pins Setup
  pinMode (Bay1CoinPin, INPUT_PULLUP);
  pinMode (Bay2CoinPin, INPUT_PULLUP);
  pinMode (Bay3CoinPin, INPUT_PULLUP);
  pinMode (Bay4CoinPin, INPUT_PULLUP);
  pinMode (Bay5CoinPin, INPUT_PULLUP);

  // Bay Timer Pin Setup
  pinMode (Bay1PumpPin, INPUT_PULLUP);
  pinMode (Bay2PumpPin, INPUT_PULLUP);
  pinMode (Bay3PumpPin, INPUT_PULLUP);
  pinMode (Bay4PumpPin, INPUT_PULLUP);
  pinMode (Bay5PumpPin, INPUT_PULLUP);
  pinMode (PreSoakPumpPin, INPUT_PULLUP);
  pinMode (SpotFreePumpPin, INPUT_PULLUP);
  pinMode (TireCleanPumpPin, INPUT_PULLUP);
  pinMode (FoamBrushPumpPin, INPUT_PULLUP);

  // Led Pin Setup
  pinMode (Bay1PumpLedPin, OUTPUT);
  pinMode (Bay2PumpLedPin, OUTPUT);
  pinMode (Bay3PumpLedPin, OUTPUT);
  pinMode (Bay4PumpLedPin, OUTPUT);
  pinMode (Bay5PumpLedPin, OUTPUT);
  pinMode (PreSoakPumpLedPin, OUTPUT);
  pinMode (SpotFreePumpLedPin, OUTPUT);
  pinMode (TireCleanPumpLedPin, OUTPUT);
  pinMode (FoamBrushPumpLedPin, OUTPUT);


}





void loop() {
  // LCD Display Loop

  // Count Loop
  //Bay 1
  Bay1CoinPinState = digitalRead(Bay1CoinPin);
  if ((Bay1CoinPinState == 1) && (Bay1CoinHit == false))
  {
    Bay1CoinCount ++ ;
    Bay1CoinHit = true;
  }
  else if ((Bay1CoinPinState) == 0 && (Bay1CoinHit == true))
  {
    Bay1CoinHit = false;
  }
  // Bay 2
  Bay2CoinPinState = digitalRead(Bay2CoinPin);
  if ((Bay2CoinPinState == 1) && (Bay2CoinHit == false))
  {
    Bay2CoinCount ++ ;
    Bay2CoinHit = true;
  }
  else if ((Bay3CoinPinState) == 0 && (Bay3CoinHit == true))
  {
    Bay3CoinHit = false;
  }
  // Bay 3
  Bay3CoinPinState = digitalRead(Bay3CoinPin);
  if ((Bay3CoinPinState == 1) && (Bay3CoinHit == false))
  {
    Bay3CoinCount ++ ;
    Bay3CoinHit = true;
  }
  else if ((Bay3CoinPinState) == 0 && (Bay3CoinHit == true))
  {
    Bay3CoinHit = false;
  }
  // Bay 4
  Bay4CoinPinState = digitalRead(Bay4CoinPin);
  if ((Bay4CoinPinState == 1) && (Bay4CoinHit == false))
  {
    Bay4CoinCount ++ ;
    Bay4CoinHit = true;
  }
  else if ((Bay4CoinPinState) == 0 && (Bay4CoinHit == true))
  {
    Bay4CoinHit = false;
  }
  // Bay 5
  Bay5CoinPinState = digitalRead(Bay5CoinPin);
  if ((Bay5CoinPinState == 1) && (Bay5CoinHit == false))
  {
    Bay5CoinCount ++ ;
    Bay5CoinHit = true;
  }
  else if ((Bay5CoinPinState) == 0 && (Bay5CoinHit == true))
  {
    Bay5CoinHit = false;
  }
  // Timer loop

  // LED Loop
  // Print loop
  Serial.print("Bay 1 Count ");
  Serial.println (Bay1CoinCount);
  Serial.print("Bay 2 Count ");
  Serial.println (Bay2CoinCount);
  Serial.print("Bay 3 Count ");
  Serial.println (Bay3CoinCount);
  Serial.print("Bay 4 Count ");
  Serial.println (Bay4CoinCount);
  Serial.print("Bay 5 Count ");
  Serial.println (Bay5CoinCount);

  delay(dt);
}

the first problem is how will you sense when the pumps are ON/OFF
I assume the pumps are AC mains operated - you could use non invasive Current_Clamp_SCT_013 to sense when a pump is operating
how many pumps are there and how far away from each other are they (in particular the controllers)
I assume you will require the pumps to report results to a central location - how far away from the pumps?

also have a look and see if the pump controllers have a means to report status, e.g. a RS323, RS485 or even a WiFi facility

Hello
To start with the basic engineering for your project post a blockdiagram showing all used components and related interfaces.

Have a nice day and enjoy coding in C++.
Дайте миру шанс!

Hello mbertsch921
For a beginner this is a good start to the program. Some suggestions:

  1. you have to declare the variables a little bit differently, not all of them are 'int'.

  2. I changed the way to handle the detection of the coins, it was correct and I wanted to make it more readable.
    be careful, it reads 1 or 0 when the coin passes through the reader ? for the moment, you have put "1", but it is to be confirmed.

Do you have the mega2560 ready to start testing?
.
.

// LCD Display
#include <Wire.h>
#include <EEPROM.h>

// Coin Count Pulse Pins
const int Bay1CoinPin = 22;
const int Bay2CoinPin = 23;
const int Bay3CoinPin = 24;
const int Bay4CoinPin = 25;
const int Bay5CoinPin = 26;

int Bay1CoinCount;
int Bay2CoinCount;
int Bay3CoinCount;
int Bay4CoinCount;
int Bay5CoinCount;

boolean Bay1CoinPinState;
boolean Bay2CoinPinState;
boolean Bay3CoinPinState;
boolean Bay4CoinPinState;
boolean Bay5CoinPinState;
boolean Bay1CoinHit;
boolean Bay2CoinHit;
boolean Bay3CoinHit;
boolean Bay4CoinHit;
boolean Bay5CoinHit;

// Pump Timer Pins
const int Bay1PumpPin = 27;
const int Bay2PumpPin = 28;
const int Bay3PumpPin = 29;
const int Bay4PumpPin = 30;
const int Bay5PumpPin = 31;
const int PreSoakPumpPin = 32;
const int SpotFreePumpPin = 33;
const int TireCleanPumpPin = 34;
const int FoamBrushPumpPin = 35;

// Pump time
int Bay1PumpTime;
int Bay2PumpTime;
int Bay3PumpTime;
int Bay4PumpTime;
int Bay5PumpTime;
int PreSoakPumpTime;
int SpotFreePumpTime;
int TireCleanPumpTime;
int FoamBrushPumpTime;

// Pump Total time
int Bay1PumpTotalTime;
int Bay2PumpTotalTime;
int Bay3PumpTotalTime;
int Bay4PumpTotalTime;
int Bay5PumpTotalTime;
int PreSoakPumpTotalTime;
int SpotFreePumpTotalTime;
int TireCleanPumpTotalTime;
int FoamBrushPumpTotalTime;

// Led Pins
const int Bay1PumpLedPin = 36;
const int Bay2PumpLedPin = 37;
const int Bay3PumpLedPin = 38;
const int Bay4PumpLedPin = 39;
const int Bay5PumpLedPin = 40;
const int PreSoakPumpLedPin = 41;
const int SpotFreePumpLedPin = 42;
const int TireCleanPumpLedPin = 43;
const int FoamBrushPumpLedPin = 44;




void setup() {
  Serial.begin(112500);
  Serial.print("Created: ");
  Serial.print(__TIME__);
  Serial.print(", ");
  Serial.println(__DATE__);
  Serial.println(__FILE__);

  // LCD Display Setup

  // Bay Coin Pins Setup
  pinMode (Bay1CoinPin, INPUT_PULLUP);
  pinMode (Bay2CoinPin, INPUT_PULLUP);
  pinMode (Bay3CoinPin, INPUT_PULLUP);
  pinMode (Bay4CoinPin, INPUT_PULLUP);
  pinMode (Bay5CoinPin, INPUT_PULLUP);

  // Bay Timer Pin Setup
  pinMode (Bay1PumpPin, INPUT_PULLUP);
  pinMode (Bay2PumpPin, INPUT_PULLUP);
  pinMode (Bay3PumpPin, INPUT_PULLUP);
  pinMode (Bay4PumpPin, INPUT_PULLUP);
  pinMode (Bay5PumpPin, INPUT_PULLUP);
  pinMode (PreSoakPumpPin, INPUT_PULLUP);
  pinMode (SpotFreePumpPin, INPUT_PULLUP);
  pinMode (TireCleanPumpPin, INPUT_PULLUP);
  pinMode (FoamBrushPumpPin, INPUT_PULLUP);

  // Led Pin Setup
  pinMode (Bay1PumpLedPin, OUTPUT);
  pinMode (Bay2PumpLedPin, OUTPUT);
  pinMode (Bay3PumpLedPin, OUTPUT);
  pinMode (Bay4PumpLedPin, OUTPUT);
  pinMode (Bay5PumpLedPin, OUTPUT);
  pinMode (PreSoakPumpLedPin, OUTPUT);
  pinMode (SpotFreePumpLedPin, OUTPUT);
  pinMode (TireCleanPumpLedPin, OUTPUT);
  pinMode (FoamBrushPumpLedPin, OUTPUT);
}




void loop() {

  Bay1CoinPinState = digitalRead(Bay1CoinPin);                          //Bay 1 
  if (Bay1CoinPinState == 1) {
    if (Bay1CoinHit == false) {
      Bay1CoinCount++ ;
      Bay1CoinHit = true;
      printCoins ();
    }  
  } else Bay1CoinHit = false;
  
  
  Bay2CoinPinState = digitalRead(Bay2CoinPin);                          //Bay 2 
  if (Bay2CoinPinState == 1) {
    if (Bay2CoinHit == false) {
      Bay2CoinCount++ ;
      Bay2CoinHit = true;
      printCoins();      
    }  
  } else Bay2CoinHit = false;
  
  
  Bay3CoinPinState = digitalRead(Bay3CoinPin);                          //Bay 3 
  if (Bay3CoinPinState == 1) {
    if (Bay3CoinHit == false) {
      Bay3CoinCount++ ;
      Bay3CoinHit = true;
      printCoins();
    }  
  } else Bay3CoinHit = false;
 
  
  Bay4CoinPinState = digitalRead(Bay4CoinPin);                          //Bay 4 
  if (Bay4CoinPinState == 1) {
    if (Bay4CoinHit == false) {
      Bay4CoinCount++ ;
      Bay4CoinHit = true;
      printCoins();      
    }  
  } else Bay4CoinHit = false;
  
    
  Bay5CoinPinState = digitalRead(Bay5CoinPin);                          //Bay 5 
  if (Bay5CoinPinState == 1) {
    if (Bay5CoinHit == false) {
      Bay5CoinCount++ ;
      Bay5CoinHit = true;
      printCoins();      
    }  
  } else Bay5CoinHit = false;
  
    
  // Timer loop

  // LED Loop
}



void printCoins (void) {
  Serial.print("Bay 1 Count ");
  Serial.println (Bay1CoinCount);
  Serial.print("Bay 2 Count ");
  Serial.println (Bay2CoinCount);
  Serial.print("Bay 3 Count ");
  Serial.println (Bay3CoinCount);
  Serial.print("Bay 4 Count ");
  Serial.println (Bay4CoinCount);
  Serial.print("Bay 5 Count ");
  Serial.println (Bay5CoinCount);
}  

Any time you find yourself creating variables with names like Bay3PumpLedPin, it's a hint that you should read up on arrays.

you are correct the pumps are 220 3phase but they all have a 24 pickup coil i am going to run a wire to the 24v side of the pick up coil to a dst-1r8p-p board and i do have Wi-Fi in the building and yes I'm sorry I forgot to mention my Arduino mega has Wi-Fi on it as far as the pump system it was put in in the 80s there is not much high tech about it

I don't disagree with you i looked at how to do arrays but correct me if I'm wrong arrays are taking multiple inputs and putting them into one basket correct meaning say i have pins 2,3,4,5,6,7,8 and i output one number or am i thinking of that wrong? but i would like to keep them separate so i can read each pump and bay separate

Almost certainly, or at least too narrowly

sounds like you could use the 24volt pickup to sense if pump is ON/OFF
run thru a rectifier plus capacitor to get a DC level and then use a potential divider to get to voltage suitable for an arduino

ok i can do that can i ask why like i said im trying to learn alot can you please explain...

not yet i am working on wiring it all up to bench test at the moment

can you please go more into depth??

Hello mbertsch921
May I use your sketch in the next lecture on structured programming as a "good example" of spaghetti programming?

Have a nice day and enjoy coding in C++.
Дайте миру шанс!

In my program example, I corrected your variable declaration (you had declared everything as "int")

Variables that must receive a numerical value can be declared as "int" (those that will contain a value between 0 and 65.535 for example)

variables that will receive a true/false state must be declared as "boolean".

the declaration of the pins of the arduino must be preceded by "const".

All these are writing conventions.

For now, I don't recommend using arrays or advanced programming, just do things one by one, to better understand what you do

If unsigned, else -32,768 to 32,767.

source