noobs need some help.

Hye all.. i am a student from malaysia.
i have to finish my school final year project.
i want to build a simple machine something like a vending machine to dispense a ticket.
i have a basic in electronic. but i am totally noob in arduino.
can someone help me to do the coding to complete my project? i dont know if you can understand or not what i want to do with the controller. please see the photo attached to understand what i mean.
im really appreciate if someone can help me out. :slight_smile:
oh forgot to tell. im using the arduino uno r3 for the controller + sparkfun 6type multicoin acceptor.
thank yo very much!

Break the project into pieces. Maybe start with the button and LEDs as they are the easiest and there is example code included with the IDE for both. Then the LCD (I suggest an I2C LCD) and servo (more examples included with the liquid crystal and servo libraries). Save the coin acceptor for last as it looks more difficult to program and learning the other stuff first may give you more insight into programming. Once you have all of the pieces put them together into one sketch. This thread will help with building your final program planning a program

I would use a switch case statement to decide how much money to add to the total. Like this:

  switch (numberofpulses) {
    case 1:
      //do something when var equals 1
      total=total+10;
      break;
    case 2:
      //do something when var equals 2
      total=total+20;
      break;
    case 3: 
     //do something when var equals 3
     total=total+50;
     break;
     default:
     //if no pulses:
     /*put code here to display current total and say how much more needed*/
     
  }

Hope this bit helps. You'll need a lot more but thats a start.

thanks for reply. really appreciate. :slight_smile:
the coin acceptor is already programmed to make/generate the output pulse signal:
10 cent = 1 pulse
20 cent = 2 pulse
50 cent = 5 pulse

this is my connection diagram.

my friend give me this code to use. but i dont understand it.
im totally noob. :frowning: :frowning:

#include <Wire.h>  // Comes with Arduino IDE
#include <LiquidCrystal_I2C.h>  // Run Library.


LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3,POSITIVE);  // Set the LCD I2C address given way to send data from the microcontroller entered the LCD.

int buttonPin =3;         // Set leg to get information from a vending machine.
int buttonState =0;         // Set the status of buttonPin
int A = 0;            // Define The display


void setup() 
{
  pinMode(buttonPin,INPUT);      // Set of legs to stand butttonPin input.
  /*
  lcd.begin(16, 2);         // Define the columns and rows of the LCD.
   lcd.setCursor(4,0);         // Set the initial position of the cursor position (4,0).
   lcd.print("WELCOME");      // Display screen LCD.
   lcd.setCursor(0,1);         // Set the initial position of the cursor position (0,1).
   lcd.print("PLZ  INSERT COIN");      // Display screen LCD.
   */
  Serial.begin(9600);  // Used to type in characters

  lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight


  //-------- Write characters on the display ------------------
  // NOTE: Cursor Position: (CHAR, LINE) start at 0  
  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("Welcome!");
  delay(1000);
  lcd.setCursor(0,1);
  lcd.print("PLZ Insert Coin");
  delay(8000);  

  // Wait and then tell user they can start the Serial Monitor and type in characters to
  // Display. (Set Serial Monitor option to "No Line Ending")
  lcd.clear();
  lcd.setCursor(0,0); //Start at character 0 on line 0
}

void loop()
{
  buttonState = digitalRead(buttonPin);   // Store the buttonPin In buttonState
  lcd.setCursor(0,0);         // Set the initial position of the cursor at (0,0).
  if(buttonState==LOW)         // conditions.
  {
    A+=10;            // Calculate the value added By increments of 5
    delay(500);                        // Define a delay 500ms.
    lcd.clear();            // Clear the entire LCD screen.
    lcd.print("CREDIT");         // Display screen LCD.
    lcd.setCursor(8,0);         // Set the initial position of the cursor position (8,0).
    lcd.print(A);            // Show the value of the variable A to the screen LCD.
    lcd.setCursor(12,0);         // Set the initial position of the cursor position (8,0).
    lcd.print("BATH");          // Display screen LCD.
  }
}

Maybe I'm missing something but, as a school project, shouldn't you be the one doing the work?

theviper0308:
... but i am totally noob in arduino.

With 3 to 4 weeks of working through some example sketches; looking at tutorials on the net; and asking specific questions about things you don't understand, you should have enough knowledge to complete your task.

Good luck

I agree with Magicj. We are willing to help with specific questions, but will not write code for you and I am not willing to try to explain the whole sketch. As I said in my original reply, break the project into pieces. We could start with the pushbutton switch on the breadboard. What is it supposed to do? Is it wired correctly? You are probably going to need a different power supply for the servo. A bit of research will tell you why.

What does the code in reply 3 actually do?

theviper0308:
Hye all.. i am a student from malaysia.
i have to finish my school final year project.

Do kids in UK schools get projects like this ?

...R