Author Topic: Basic Programming help  (Read 1654 times)

0 Members and 1 Guest are viewing this topic.

Offline I Am BlashyrkhTopic starter

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 0
Basic Programming help
« on: August 24, 2009, 06:38:06 PM »
Im a sculptor and Im planning a piece that mimics a vending machine. What I basically want is 4-6 switches that control 4-6 servos and I want them to only run for a designated period. They would be modified for continuous rotation but I want the corresponding servo to only run for a designated time (about 30 seconds) once the button is pushed. I can handle the mechanics that will cause the item to be dispensed but I dont know how to write the code. Also I was wondering if I could use a roboduino board that I got a while back for a photovore project? I figure I would have to modify it in some way to create more ports for the servos and the switches but would it work for this project? And if so, what would the code look like? Does anyone know of other project codes for something similar that I could modify? I obviously dont know much about writing code but I might be able to modify some code if need be. Can anyone help me out? I will gladly show off the results when it is completed. Its actually going to be a coke machine like thing that dispenses tubed fetuses (fake fetuses obviously).

I know this is probably really basic but programming is not my game. Im more of a mechanical guy. If I could do this with just motors and without the circuitry I would but I need a little more control.

Offline jaime

  • Jr. Member
  • **
  • Posts: 30
  • Helpful? 1
Re: Basic Programming help
« Reply #1 on: August 25, 2009, 08:52:42 AM »
I think you need to lay out your algorithm, and then someone here could probably help you a bit more.  Maybe something like this:

loop forever:
    #If the machine is vending, don't start vending another fetus (gross)
    if vending():
        continue

    button_pressed = get_depressed_button()
    
    if button_pressed != NO_BUTTON_PRESSED:
        # A button was pressed, dispense using the correct servo
        vend_item(button_pressed)

# Helper functions
def get_depressed_button():
    # Somehow reads sensor data and returns a constant that is associated with
    # the button
    return CORRECT_BUTTON

def vend_item(button):
    turn appropriate servo based on button pressed
    setup timer to turn off servo in XX seconds

I think this is a good start.  Someone who actually understands robot programmign better than me can probably help you fill in the blanks!

Offline I Am BlashyrkhTopic starter

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 0
Re: Basic Programming help
« Reply #2 on: August 26, 2009, 01:52:52 PM »
Thanks for the help man. Ill look into it more and hopefully Ill be able to get this thing working.

 


data_list