Countdown time using TM1637

If 10php gives 10 pulses, then you count pulses and assign "seconds" to each pulse.

but every pulse is 1 second right now

how can I make the money I inserted in the coin slot have an equivalent time and where do I put it in my program or code and display it on the TM1637 4 digit seven segment thank you very much

Your code counts pulses.

    pulse += 1;

When your code shows the pulses on the LCD, your code calls those pulses "PhP"... so if you put "10" PhP in, your coin slot will make 10 pulses and your code will count 10 pulses, then your LCD will show "10 PhP"

yes

What is your question?

How can I make it five minutes for every 20 pesos?

Your LCD can not contain more letters. Your code must change to show TIME. Your code only registers pulses. If you insert 20PhP, your code can calculate TIME like this:

float pesosPERpulse = 0.25;

Then you would use number of pesos (pulses)...

float timePERpesos = pulse * pesosPERpulse;

Your "timePERpesos" would then equal 20 * 0.25 = 5... and you would use that "5" to display "5 minutes" on your LCD.

where did i put in the code?

and another question how can display the time in the TM1637 4 digit 7 segment?

sorry for this im new in programming in ardino

You use the IDE to upload the code to the Arduino.

You will need to understand RTC, then use the RTC information to create the time on the TM1637.

You can find many examples on the internet.

1 Like

You should start with the Built-In Examples in the IDE.

IDE >> FILE >> EXAMPLES >> BUILT-IN EXAMPLES >> (pick an example)

1 Like
  • Your code is using an LCD display.
  • Do you want to add an another 7-segment display?
  • Can you post a pic of your display?

yes i used IDE but how to construct the code

Processing: 17233348140154542362058635159802.jpg…

Here the image

float pesosPERpulse = 0.25;

Then you would use number of pesos (pulses)...

float timePERpesos = pulse * pesosPERpulse;

my "timePERpesos" would then equal 20 * 0.25 = 5... and you would use that "5" to display "5 minutes" on your LCD.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

#define coinSlot 6
#define buzzer 13
#define button 4

int coinSlotStatus;
int pulse;

boolean userBalance = false;
boolean noCoin = false;

char lcdBuffer[16];

int buttonState;

void setup() {
  lcd.init();
  lcd.backlight();
  lcd.clear();
  pinMode(buzzer, OUTPUT);
  pinMode(10, OUTPUT);
  digitalWrite(10, LOW);
  pinMode(coinSlot, INPUT_PULLUP);
  pinMode(button, OUTPUT);
  tone(buzzer, 262);
  delay(150);
  tone(buzzer, 294);
  delay(150);
  tone(buzzer, 330);
  delay(150);
  tone(buzzer, 349);
  delay(150);
  tone(buzzer, 392);
  delay(150);
  tone(buzzer, 440);
  delay(150);
  tone(buzzer, 394);
  delay(150);
  tone(buzzer, 563);
  delay(150);
  noTone(buzzer);
  delay(1000);
}

void loop() {
  if (noCoin == false) {
    noCoin = true;
    lcd.setCursor(0, 0);
    lcd.print(" Insert Coin");
  }


  buttonState = digitalRead(button);

  if (buttonState == 1 && pulse > 0 && userBalance) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Pumping Liquid");

    for (int i = pulse; i > 0; i--) {
      lcd.setCursor(0, 1);
      lcd.print("   ");
      lcd.setCursor(0, 1);
      lcd.print(i);
      tone(buzzer,523);
      delay(500);
      noTone(buzzer);
      delay(500);
    }

    pulse = 0;
    noCoin = false;
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(" Thank You Bye!");
    delay(1700);
    tone(buzzer, 3000);
    delay(200);
    noTone(buzzer);
    delay(50);
    tone(buzzer, 3000);
    delay(50);
    noTone(buzzer);


  }


  coinSlotStatus = digitalRead(coinSlot);
  delay(30);
  if (coinSlotStatus == 0) {
    userBalance = true;
    lcd.setCursor(0, 0);
    lcd.print("Press a Button");
    pulse += 1;
    lcd.setCursor(0, 1);
    sprintf(lcdBuffer, "Bal. Php %d.00", pulse);
    lcd.setCursor(0, 1);
    lcd.print(lcdBuffer);
    delay(30);
  }
  noTone(buzzer);
}

You learn.

If 20 PHP = 5 minutes (300 seconds), 1PHP = 300 / 20 = 15. 1 PHP = 15 seconds of time.

what is the sample code for this statement i used and where i put in my code i learn how to use the tm1637 display but it shows always every 1 pulse is 1 sec. how to make 20 PHP = 5minutes that's the limit of the timer thank for your help i need this to my project

If you want people to do your work, just say it.

SAME-SAME post #23

float pesosPERpulse = 0.25;

Then you would use number of pesos (pulses)...

float timePERpesos = pulse * pesosPERpulse;

my "timePERpesos" would then equal 20 * 0.25 = 5... and you would use that "5" to display "5 minutes" on your LCD.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

#define coinSlot 6
#define buzzer 13
#define button 4

int coinSlotStatus;
int pulse;

boolean userBalance = false;
boolean noCoin = false;

char lcdBuffer[16];

int buttonState;

void setup() {
  lcd.init();
  lcd.backlight();
  lcd.clear();
  pinMode(buzzer, OUTPUT);
  pinMode(10, OUTPUT);
  digitalWrite(10, LOW);
  pinMode(coinSlot, INPUT_PULLUP);
  pinMode(button, OUTPUT);
  tone(buzzer, 262);
  delay(150);
  tone(buzzer, 294);
  delay(150);
  tone(buzzer, 330);
  delay(150);
  tone(buzzer, 349);
  delay(150);
  tone(buzzer, 392);
  delay(150);
  tone(buzzer, 440);
  delay(150);
  tone(buzzer, 394);
  delay(150);
  tone(buzzer, 563);
  delay(150);
  noTone(buzzer);
  delay(1000);
}

void loop() {
  if (noCoin == false) {
    noCoin = true;
    lcd.setCursor(0, 0);
    lcd.print(" Insert Coin");
  }


  buttonState = digitalRead(button);

  if (buttonState == 1 && pulse > 0 && userBalance) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Pumping Liquid");

    for (int i = pulse; i > 0; i--) {
      lcd.setCursor(0, 1);
      lcd.print("   ");
      lcd.setCursor(0, 1);
      lcd.print(i);
      tone(buzzer,523);
      delay(500);
      noTone(buzzer);
      delay(500);
    }

    pulse = 0;
    noCoin = false;
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(" Thank You Bye!");
    delay(1700);
    tone(buzzer, 3000);
    delay(200);
    noTone(buzzer);
    delay(50);
    tone(buzzer, 3000);
    delay(50);
    noTone(buzzer);


  }


  coinSlotStatus = digitalRead(coinSlot);
  delay(30);
  if (coinSlotStatus == 0) {
    userBalance = true;
    lcd.setCursor(0, 0);
    lcd.print("Press a Button");
    pulse += 1;
    lcd.setCursor(0, 1);
    sprintf(lcdBuffer, "Bal. Php %d.00", pulse);
    lcd.setCursor(0, 1);
    lcd.print(lcdBuffer);
    delay(30);
  }
  noTone(buzzer);
}