Coin counter project for school

is it possible to gather all the gnd and they share a same gnd in adruino?

very weak idea to make 9V from 12V and try to power everything from 5V off arduino.
usually buck converter is set to 5V and powering everything.
even more weak to connect relay coil to arduino digital pin.

1 Like

whats your suggestion sir?when i power the arduino the lcd is counting and the hopper is dispensing without pressing the button

try this

#define START_BUTTON_PIN 7       // Pin for Start button
#define RELAY_PIN A0              // Pin for relay control
#define COIN_HOPPER_PIN 8        // Pin for coin hopper pulse

void setup() {

  pinMode(START_BUTTON_PIN, INPUT_PULLUP);
  pinMode(COIN_HOPPER_PIN, INPUT_PULLUP);

  // Start with the relay off
  digitalWrite(RELAY_PIN, HIGH);
  pinMode(RELAY_PIN, OUTPUT);

}

void loop() {
  digitalWrite(RELAY_PIN, digitalRead(COIN_HOPPER_PIN) );
}
1 Like

this is for testing?

wait sir i will try this one

Try switching on the power to the coin hopper with the Arduino and relay module unpowered.
The coin hopper should not run (assuming you have used the Normally Open contact of the relay).

1 Like

i already try but the button is not responding when i press

"start" button? is it damaged?

1 Like

i dont know sir..at my first attempt i put the red wire of the coin sensor to vin in arduino, the hopper is not starting when i change it to the pic 5v the hopper starts when i power up the arduino

all the ground from the hopper, relay and button share the same ground of the arduino

so you need no relay on 230V side

test your button:

#define START_BUTTON_PIN 7       // Pin for Start button

void setup() {

  pinMode(START_BUTTON_PIN, INPUT_PULLUP);

  pinMode(13, OUTPUT);

}

void loop() {
  digitalWrite(13, digitalRead(START_BUTTON_PIN) );
}
1 Like

what will happen if i use this code?

i see i try the code..the led of the arduino responding when i press the button

it is good, button not damaged.

try this

#define START_BUTTON_PIN 7       // Pin for Start button
#define RELAY_PIN A0              // Pin for relay control
#define COIN_HOPPER_PIN 8        // Pin for coin hopper pulse

void setup() {

  pinMode(START_BUTTON_PIN, INPUT_PULLUP);
  pinMode(COIN_HOPPER_PIN, INPUT_PULLUP);

  // Start with the relay off
  //digitalWrite(RELAY_PIN, HIGH);
  pinMode(RELAY_PIN, OUTPUT);
 pinMode(13, OUTPUT);

}

void loop() {
  digitalWrite(RELAY_PIN, !digitalRead(START_BUTTON_PIN) );
 digitalWrite(13, digitalRead(COIN_HOPPER_PIN) );
}

during startup of the arduino the coin hopper starts on when i press the button the coin hopper off and when i release the button the hopper will start on again

ok, i have edited that sketch and logic now inverted

1 Like

is it ok sir all the led of the arduino is all on?

when i hold press the button the hopper on and when i release it the hopper off