Peamy115500
Published © MPL-2.0

Electronic Piggy Bank

Counting coins made easy.

IntermediateShowcase (no instructions)535
Electronic Piggy Bank

Things used in this project

Hardware components

Infrared Module (Generic)
×4
Switch Actuator, Head for spring return push-button
Switch Actuator, Head for spring return push-button
×1
Alphanumeric LCD, 16 x 2
Alphanumeric LCD, 16 x 2
×1

Story

Read more

Schematics

12_moneycollector_02-1_RdiuVe3xIX.jpg

Code

sketch_apr10a.ino

C/C++
    }
  }
  else if(digitalRead(Baht3)==HIGH)
  {
    if(FlagCoin == false)
    {
       FlagCoin = true;
       CntDelayCoin = 0;
       
       BuffCoin+=3;
    }
  }
  else if(digitalRead(Baht5)==HIGH)
  {
    if(FlagCoin == false)
    {
       FlagCoin = true;
       CntDelayCoin = 0;
       
       BuffCoin+=5;
    }
  }
  else
  {
    FlagCoin = false;
  }
  
  ////////////// Count Coin //////////////
  if(CntDelayCoin<20){CntDelayCoin++;}
  else
  {
    if(BuffCoin==1)          // Type 1Baht
    {
      Coin_1++; 
      EEPROM.write(0,Coin_1);
    }
    else if(BuffCoin==2)     // Type 2Baht
    {
      Coin_2++;
      EEPROM.write(1,Coin_2);
    }
    else if(BuffCoin==5)
    {
      Coin_5++;
      EEPROM.write(2,Coin_5);
    }
    else if(BuffCoin==10)
    {
      Coin_10++; 
      EEPROM.write(3,Coin_10);
    }
    BuffCoin = 0;
  }
  
  /////////////// Show Lcd /////////////////
  lcd.setCursor(0,0);
  lcd.print("[1]");
  lcd.print(Coin_1);
  lcd.print(" ");

  lcd.print("[2]");
  lcd.print(Coin_2);
  lcd.print(" ");
  
  lcd.print("[5]");
  lcd.print(Coin_5);
  lcd.print(" ");
  
  lcd.setCursor(0,1);
  lcd.print("[10]");
  lcd.print(Coin_10);
  lcd.print(" ");
  
  int ToTalBaht = (Coin_1+(Coin_2*2)+(Coin_5*5)+(Coin_10*10));
  lcd.print(" T=");
  lcd.print(ToTalBaht);
  lcd.print("Baht    ");
  ///////////////////////////////////////////
  delay(50);
}

Credits

Peamy115500
0 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.