Shop OBEX P1 Docs P2 Docs Learn Events
Would a Propeller Activity Board be good for a one-off children's toy? - Page 2 — Parallax Forums

Would a Propeller Activity Board be good for a one-off children's toy?

2»

Comments

  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2014-03-30 14:36
    Wow! That is coming together really nice. Will it be heavy enough to be stable during "racing"? Hard to tell exactly how big it is, but it does appear bulky enough to be solid. The layout is well done, puts the switches, leds, etc real close. Can't wait to see more pics.
  • gwtthrgwtthr Posts: 30
    edited 2014-04-01 18:38
    That's a very good question, unfortunately at this point I haven't bolted the steering wheel to the console yet to try it. As I built the console the thought that it may be too light never crossed my mind (that's how bulky it is). Oh well. One more thing to add to the to do list.

    If each end of the console ends up lifting as you steer, I guess I could always take out the motor that provides the feedback in the steering wheel, allowing it to turn with no resistance.
  • gwtthrgwtthr Posts: 30
    edited 2014-04-02 18:09
    To aid in laying out my wiring on the activity board I went looking for a blank image of the bread board. I wanted to print a blank one out on paper so I could draw on it. I didn't find one in the first few results of Google, so I made a quick and dirty one using photo editing software. I thought I might share it in case anyone else might need it.

    Propeller Act Board.jpg
    1024 x 1349 - 124K
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-04-03 18:11
    gwtthr wrote: »
    To aid in laying out my wiring on the activity board I went looking for a blank image of the bread board. I wanted to print a blank one out on paper so I could draw on it. I didn't find one in the first few results of Google, so I made a quick and dirty one using photo editing software. I thought I might share it in case anyone else might need it.

    Propeller Act Board.jpg

    Nice! Thank you!!
  • gwtthrgwtthr Posts: 30
    edited 2014-04-09 18:45
    Apparently I'm not having luck with using a Veho 360 speaker for this project. When I plug it in to charge it (with the provided cable), the charge cable is getting too hot to touch. Has anyone else ran into this? The only thing I can think that has happened to the speaker is that it has been run until the battery was dead. Considering there is a lipo battery inside, does it not have any kind of protection from this?
  • gwtthrgwtthr Posts: 30
    edited 2014-04-11 18:26
    What does it mean when your Act Board locks up while running through it's program and LED P26 and P27 light up on the board? I didn't program them to do anything?
  • gwtthrgwtthr Posts: 30
    edited 2014-04-13 11:04
    Okay, looks like I've found my problem. "Your program is too big for the memory model selected in the project." I've entered the correct pause length for each of the recorded sounds in my code, and I'm running out of memory. Any suggestions? Is there another memory model I can try?
  • jazzedjazzed Posts: 11,803
    edited 2014-04-13 11:46
    gwtthr wrote: »
    Okay, looks like I've found my problem. "Your program is too bid for the memory model selected in the project." I've entered the correct pause length for each of the recorded sounds in my code, and I'm running out of memory. Any suggestions? Is there another memory model I can try?
    Open the program manager panel and choose "CMM Main RAM Compact" from the Memory Model selection.

    There may be other possibilities .... Can you list all of the items you are trying to do ?

    If you are willing to share your code, there may be some things that one of us can spot that might need some adjustments.
  • gwtthrgwtthr Posts: 30
    edited 2014-04-16 17:00
    Okay this is my first attempt at posting code, and please don't laugh at the brute force/simple method I used to create such long code. It's written just as the C just as the Parallax examples are. It's fairly simple code and to create it I only had to copy and paste things multiple times.

    Program explanation:

    The program runs in an infinite loop. It checks the status of every single available input on the board (P0-P15). All the inputs are connected to simple buttons and toggle switches. The toggle switches are P0-P3 (green). The combination of on-off positions and logic put the toy into a mode (i.e.- the types of sounds that play, train, car, boat). Once into the corresponding function of that mode the program just checks to see what of the remaining inputs has a button pushed. It plays a recorded sound from the micro SD card and the loop starts again.

    It is not in the code currently, but I intend to have two servos moving with each corresponding sound play. The servos will be made into gauges that will move with each sound. I've tried taking the #include "servo.h" out, but this program seems to be long still. I've got a shorter version missing last four of the (modes) functions. It works great, but when the servo header is included it won't work.

    Those of you with more C experience could probably find a way to have one function called that could be manipulated into playing the correct mode.

    Here is a shot of the board wired up...

    Nov Dec 2013.jpg


    Code:

    [php]

    /* Final program V1.5
    */


    #include "simpletools.h"
    #include "wavplayer.h"
    #include "simpletools.h"
    #include "servo.h"




    // Declare functions and inputs to those functions




    int Car(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Racecar(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Semi(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Prop(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Airl(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Jetf(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Heli(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Train(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Enter(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Tief(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Milf(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Ship(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int BTFG(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Cont(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Btle(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);
    int Tank(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15);




    int main() // main function
    {
    int DO = 22, CLK = 23, DI = 24, CS = 25; // SD I/O pins
    sd_mount(DO, CLK, DI, CS); // Mount SD card


    print("start\n");
    pause(5000);


    while(1) //infinte loop
    {
    int button0 = input(0); //read in buttons
    print("button0 = %d\n", button0);
    int button1 = input(1);
    print("button1 = %d\n", button1);
    int button2 = input(2);
    print("button2 = %d\n", button2);
    int button3 = input(3);
    print("button3 = %d\n", button3);
    int button4 = input(4);
    print("button4 = %d\n", button4);
    int button5 = input(5);
    print("button5 = %d\n", button5);
    int button6 = input(6);
    print("button6 = %d\n", button6);
    int button7 = input(7);
    print("button7 = %d\n", button7);
    int button8 = input(8);
    print("button8 = %d\n", button8);
    int button9 = input(9);
    print("button9 = %d\n", button9);
    int button10 = input(10);
    print("button10 = %d\n", button10);
    int button11 = input(11);
    print("button11 = %d\n", button11);
    int button12 = input(12);
    print("button12 = %d\n", button12);
    int button13 = input(13);
    print("button13 = %d\n", button13);
    int button14 = input(14);
    print("button14 = %d\n", button14);
    int button15 = input(15);
    print("button15 = %d\n", button15);

    if((button0 == 0) && (button1 == 0) && (button2 == 0) && (button3 == 0))
    {
    print("Go to function Car\n");
    int n = Car(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 1) && (button1 == 0) && (button2 == 0) && (button3 == 0))
    {
    print("Go to funciton Racecar\n");
    int n = Racecar(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 0) && (button1 == 1) && (button2 == 0) && (button3 == 0))
    {
    print("Go to function Semi\n");
    int n = Semi(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 0) && (button1 == 0) && (button2 == 1) && (button3 == 0))
    {
    print("Go to function Prop Plane\n");
    int n = Prop(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 0) && (button1 == 0) && (button2 == 0) && (button3 == 1))
    {
    print("Go to funciton Airliner\n");
    int n = Airl(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 1) && (button1 == 1) && (button2 == 0) && (button3 == 0))
    {
    print("Go to function Jetfighter\n");
    int n = Jetf(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 1) && (button1 == 0) && (button2 == 1) && (button3 == 0))
    {
    print("Go to function Helicopter\n");
    int n = Heli(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 1) && (button1 == 0) && (button2 == 0) && (button3 == 1))
    {
    print("Go to function Train\n");
    int n = Train(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 0) && (button1 == 1) && (button2 == 1) && (button3 == 0))
    {
    print("Go to function Enterprise\n");
    int n = Enter(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 0) && (button1 == 1) && (button2 == 0) && (button3 == 1))
    {
    print("Go to function Tie fighter\n");
    int n = Tief(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 0) && (button1 == 0) && (button2 == 1) && (button3 == 1))
    {
    print("Go to function Millennium Falcon\n");
    int n = Milf(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 1) && (button1 == 1) && (button2 == 0) && (button3 == 1))
    {
    print("Go to function Ship\n");
    int n = Ship(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 1) && (button1 == 0) && (button2 == 1) && (button3 == 1))
    {
    print("Go to function Back to the Future and Ghostbusters\n");
    int n = BTFG(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 1) && (button1 == 1) && (button2 == 1) && (button3 == 0))
    {
    print("Go to function Construction Zone\n");
    int n = Cont(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 0) && (button1 == 1) && (button2 == 1) && (button3 == 1))
    {
    print("Go to function Battle Sounds\n");
    int n = Btle(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else if((button0 == 1) && (button1 == 1) && (button2 == 1) && (button3 == 1))
    {
    print("Go to function Tank\n");
    int n = Tank(button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15);
    }
    else
    {
    print("ERROR for modes\n");
    }
    }
    }

    int Car(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Car function\n");
    pause(5);
    if(button4 == 1)
    {
    const char car1[] = {"car1.wav"}; // Set up techloop string
    wav_play(car1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char car2[] = {"car2.wav"}; // Set up techloop string
    wav_play(car2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char car3[] = {"car3.wav"}; // Set up techloop string
    wav_play(car3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char car4[] = {"car4.wav"}; // Set up techloop string
    wav_play(car4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char car5[] = {"car5.wav"}; // Set up techloop string
    wav_play(car5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char car6[] = {"car6.wav"}; // Set up techloop string
    wav_play(car6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char car7[] = {"car7.wav"}; // Set up techloop string
    wav_play(car7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char car8[] = {"car8.wav"}; // Set up techloop string
    wav_play(car8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char car9[] = {"car9.wav"}; // Set up techloop string
    wav_play(car9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char car10[] = {"car10.wav"}; // Set up techloop string
    wav_play(car10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char car11[] = {"car11.wav"}; // Set up techloop string
    wav_play(car11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5800); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char car12[] = {"car12.wav"}; // Set up techloop string
    wav_play(car12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1150); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Car\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }

    int Racecar(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Racecar function\n");
    pause(500);
    if(button4 == 1)
    {
    const char rcar1[] = {"rcar1.wav"}; // Set up techloop string
    wav_play(rcar1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(825); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char rcar2[] = {"rcar2.wav"}; // Set up techloop string
    wav_play(rcar2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char rcar3[] = {"rcar3.wav"}; // Set up techloop string
    wav_play(rcar3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(2300); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char rcar4[] = {"rcar4.wav"}; // Set up techloop string
    wav_play(rcar4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char rcar5[] = {"rcar5.wav"}; // Set up techloop string
    wav_play(rcar5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(6000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char rcar6[] = {"rcar6.wav"}; // Set up techloop string
    wav_play(rcar6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1300); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char rcar7[] = {"rcar7.wav"}; // Set up techloop string
    wav_play(rcar7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char rcar8[] = {"rcar8.wav"}; // Set up techloop string
    wav_play(rcar8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char rcar9[] = {"rcar9.wav"}; // Set up techloop string
    wav_play(rcar9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(9100); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char rcar10[] = {"rcar10.wav"}; // Set up techloop string
    wav_play(rcar10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(2080); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char rcar11[] = {"rcar11.wav"}; // Set up techloop string
    wav_play(rcar11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char rcar12[] = {"rcar12.wav"}; // Set up techloop string
    wav_play(rcar12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1500); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Rcar\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }


    int Semi(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Semi function\n");
    pause(500);
    if(button4 == 1)
    {
    const char semi1[] = {"semi1.wav"}; // Set up techloop string
    wav_play(semi1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(3000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char semi2[] = {"semi2.wav"}; // Set up techloop string
    wav_play(semi2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char semi3[] = {"semi3.wav"}; // Set up techloop string
    wav_play(semi3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(6000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char semi4[] = {"semi4.wav"}; // Set up techloop string
    wav_play(semi4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(8000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char semi5[] = {"semi5.wav"}; // Set up techloop string
    wav_play(semi5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char semi6[] = {"semi6.wav"}; // Set up techloop string
    wav_play(semi6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char semi7[] = {"semi7.wav"}; // Set up techloop string
    wav_play(semi7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1500); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char semi8[] = {"semi8.wav"}; // Set up techloop string
    wav_play(semi8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(2200); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char semi9[] = {"semi9.wav"}; // Set up techloop string
    wav_play(semi9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1100); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char semi10[] = {"semi10.wav"}; // Set up techloop string
    wav_play(semi10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char semi11[] = {"semi11.wav"}; // Set up techloop string
    wav_play(semi11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char semi12[] = {"semi12.wav"}; // Set up techloop string
    wav_play(semi12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Semi\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }


    int Prop(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Prop Plane function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Prop1[] = {"Prop1.wav"}; // Set up techloop string
    wav_play(Prop1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(2500); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Prop2[] = {"Prop2.wav"}; // Set up techloop string
    wav_play(Prop2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(6600); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Prop3[] = {"Prop3.wav"}; // Set up techloop string
    wav_play(Prop3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(2200); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Prop4[] = {"Prop4.wav"}; // Set up techloop string
    wav_play(Prop4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Prop5[] = {"Prop5.wav"}; // Set up techloop string
    wav_play(Prop5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(7300); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Prop6[] = {"Prop6.wav"}; // Set up techloop string
    wav_play(Prop6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5200); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Prop7[] = {"Prop7.wav"}; // Set up techloop string
    wav_play(Prop7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Prop8[] = {"Prop8.wav"}; // Set up techloop string
    wav_play(Prop8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Prop9[] = {"Prop9.wav"}; // Set up techloop string
    wav_play(Prop9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(7300); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Prop10[] = {"Prop10.wav"}; // Set up techloop string
    wav_play(Prop10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Prop11[] = {"Prop11.wav"}; // Set up techloop string
    wav_play(Prop11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Prop12[] = {"Prop12.wav"}; // Set up techloop string
    wav_play(Prop12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Prop Plane\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }


    int Airl(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Airliner function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Airl1[] = {"Airl1.wav"}; // Set up techloop string
    wav_play(Airl1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(4500); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Airl2[] = {"Airl2.wav"}; // Set up techloop string
    wav_play(Airl2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(4000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Airl3[] = {"Airl3.wav"}; // Set up techloop string
    wav_play(Airl3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(7000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Airl4[] = {"Airl4.wav"}; // Set up techloop string
    wav_play(Airl4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(4200); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Airl5[] = {"Airl5.wav"}; // Set up techloop string
    wav_play(Airl5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Airl6[] = {"Airl6.wav"}; // Set up techloop string
    wav_play(Airl6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1250); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Airl7[] = {"Airl7.wav"}; // Set up techloop string
    wav_play(Airl7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(900); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Airl8[] = {"Airl8.wav"}; // Set up techloop string
    wav_play(Airl8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(3000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Airl9[] = {"Airl9.wav"}; // Set up techloop string
    wav_play(Airl9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(9000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Airl10[] = {"Airl10.wav"}; // Set up techloop string
    wav_play(Airl10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(8000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Airl11[] = {"Airl11.wav"}; // Set up techloop string
    wav_play(Airl11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(2230); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Airl12[] = {"Airl12.wav"}; // Set up techloop string
    wav_play(Airl12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Airl\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }


    int Jetf(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Jetf function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Jetf1[] = {"Jetf1.wav"}; // Set up techloop string
    wav_play(Jetf1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Jetf2[] = {"Jetf2.wav"}; // Set up techloop string
    wav_play(Jetf2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Jetf3[] = {"Jetf3.wav"}; // Set up techloop string
    wav_play(Jetf3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Jetf4[] = {"Jetf4.wav"}; // Set up techloop string
    wav_play(Jetf4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Jetf5[] = {"Jetf5.wav"}; // Set up techloop string
    wav_play(Jetf5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Jetf6[] = {"Jetf6.wav"}; // Set up techloop string
    wav_play(Jetf6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Jetf7[] = {"Jetf7.wav"}; // Set up techloop string
    wav_play(Jetf7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Jetf8[] = {"Jetf8.wav"}; // Set up techloop string
    wav_play(Jetf8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Jetf9[] = {"Jetf9.wav"}; // Set up techloop string
    wav_play(Jetf9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Jetf10[] = {"Jetf10.wav"}; // Set up techloop string
    wav_play(Jetf10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Jetf11[] = {"Jetf11.wav"}; // Set up techloop string
    wav_play(Jetf11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Jetf12[] = {"Jetf12.wav"}; // Set up techloop string
    wav_play(Jetf12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Jetf\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }


    int Heli(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Helicopter function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Heli1[] = {"Heli1.wav"}; // Set up techloop string
    wav_play(Heli1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Heli2[] = {"Heli2.wav"}; // Set up techloop string
    wav_play(Heli2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Heli3[] = {"Heli3.wav"}; // Set up techloop string
    wav_play(Heli3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Heli4[] = {"Heli4.wav"}; // Set up techloop string
    wav_play(Heli4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Heli5[] = {"Heli5.wav"}; // Set up techloop string
    wav_play(Heli5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Heli6[] = {"Heli6.wav"}; // Set up techloop string
    wav_play(Heli6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Heli7[] = {"Heli7.wav"}; // Set up techloop string
    wav_play(Heli7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Heli8[] = {"Heli8.wav"}; // Set up techloop string
    wav_play(Heli8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Heli9[] = {"Heli9.wav"}; // Set up techloop string
    wav_play(Heli9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Heli10[] = {"Heli10.wav"}; // Set up techloop string
    wav_play(Heli10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Heli11[] = {"Heli11.wav"}; // Set up techloop string
    wav_play(Heli11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Heli12[] = {"Heli12.wav"}; // Set up techloop string
    wav_play(Heli12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Heli\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }

    [/php]
    1024 x 678 - 127K
  • gwtthrgwtthr Posts: 30
    edited 2014-04-16 17:02
    Too long of code. Had to break it up.

    [php]
    int Train(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Train function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Train1[] = {"Train1.wav"}; // Set up techloop string
    wav_play(Train1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Train2[] = {"Train2.wav"}; // Set up techloop string
    wav_play(Train2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Train3[] = {"Train3.wav"}; // Set up techloop string
    wav_play(Train3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Train4[] = {"Train4.wav"}; // Set up techloop string
    wav_play(Train4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Train5[] = {"Train5.wav"}; // Set up techloop string
    wav_play(Train5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Train6[] = {"Train6.wav"}; // Set up techloop string
    wav_play(Train6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Train7[] = {"Train7.wav"}; // Set up techloop string
    wav_play(Train7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Train8[] = {"Train8.wav"}; // Set up techloop string
    wav_play(Train8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Train9[] = {"Train9.wav"}; // Set up techloop string
    wav_play(Train9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Train10[] = {"Train10.wav"}; // Set up techloop string
    wav_play(Train10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Train11[] = {"Train11.wav"}; // Set up techloop string
    wav_play(Train11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Train12[] = {"Train12.wav"}; // Set up techloop string
    wav_play(Train12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Train\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }


    int Enter(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Enterprise function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Enter1[] = {"Enter1.wav"}; // Set up techloop string
    wav_play(Enter1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Enter2[] = {"Enter2.wav"}; // Set up techloop string
    wav_play(Enter2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Enter3[] = {"Enter3.wav"}; // Set up techloop string
    wav_play(Enter3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Enter4[] = {"Enter4.wav"}; // Set up techloop string
    wav_play(Enter4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Enter5[] = {"Enter5.wav"}; // Set up techloop string
    wav_play(Enter5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Enter6[] = {"Enter6.wav"}; // Set up techloop string
    wav_play(Enter6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Enter7[] = {"Enter7.wav"}; // Set up techloop string
    wav_play(Enter7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Enter8[] = {"Enter8.wav"}; // Set up techloop string
    wav_play(Enter8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Enter9[] = {"Enter9.wav"}; // Set up techloop string
    wav_play(Enter9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Enter10[] = {"Enter10.wav"}; // Set up techloop string
    wav_play(Enter10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Enter11[] = {"Enter11.wav"}; // Set up techloop string
    wav_play(Enter11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Enter12[] = {"Enter12.wav"}; // Set up techloop string
    wav_play(Enter12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Enter\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }


    int Tief(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Tie fighter function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Tief1[] = {"Tief1.wav"}; // Set up techloop string
    wav_play(Tief1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Tief2[] = {"Tief2.wav"}; // Set up techloop string
    wav_play(Tief2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Tief3[] = {"Tief3.wav"}; // Set up techloop string
    wav_play(Tief3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Tief4[] = {"Tief4.wav"}; // Set up techloop string
    wav_play(Tief4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Tief5[] = {"Tief5.wav"}; // Set up techloop string
    wav_play(Tief5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Tief6[] = {"Tief6.wav"}; // Set up techloop string
    wav_play(Tief6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Tief7[] = {"Tief7.wav"}; // Set up techloop string
    wav_play(Tief7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Tief8[] = {"Tief8.wav"}; // Set up techloop string
    wav_play(Tief8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Tief9[] = {"Tief9.wav"}; // Set up techloop string
    wav_play(Tief9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Tief10[] = {"Tief10.wav"}; // Set up techloop string
    wav_play(Tief10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Tief11[] = {"Tief11.wav"}; // Set up techloop string
    wav_play(Tief11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Tief12[] = {"Tief12.wav"}; // Set up techloop string
    wav_play(Tief12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Tie fighter\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }


    int Milf(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Millenium falcon function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Milf1[] = {"Milf1.wav"}; // Set up techloop string
    wav_play(Milf1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Milf2[] = {"Milf2.wav"}; // Set up techloop string
    wav_play(Milf2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Milf3[] = {"Milf3.wav"}; // Set up techloop string
    wav_play(Milf3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Milf4[] = {"Milf4.wav"}; // Set up techloop string
    wav_play(Milf4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Milf5[] = {"Milf5.wav"}; // Set up techloop string
    wav_play(Milf5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Milf6[] = {"Milf6.wav"}; // Set up techloop string
    wav_play(Milf6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Milf7[] = {"Milf7.wav"}; // Set up techloop string
    wav_play(Milf7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Milf8[] = {"Milf8.wav"}; // Set up techloop string
    wav_play(Milf8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Milf9[] = {"Milf9.wav"}; // Set up techloop string
    wav_play(Milf9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Milf10[] = {"Milf10.wav"}; // Set up techloop string
    wav_play(Milf10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Milf11[] = {"Milf11.wav"}; // Set up techloop string
    wav_play(Milf11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Milf12[] = {"Milf12.wav"}; // Set up techloop string
    wav_play(Milf12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Millenium falcon\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }


    int Ship(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Ship function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Ship1[] = {"Ship1.wav"}; // Set up techloop string
    wav_play(Ship1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Ship2[] = {"Ship2.wav"}; // Set up techloop string
    wav_play(Ship2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Ship3[] = {"Ship3.wav"}; // Set up techloop string
    wav_play(Ship3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Ship4[] = {"Ship4.wav"}; // Set up techloop string
    wav_play(Ship4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Ship5[] = {"Ship5.wav"}; // Set up techloop string
    wav_play(Ship5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Ship6[] = {"Ship6.wav"}; // Set up techloop string
    wav_play(Ship6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Ship7[] = {"Ship7.wav"}; // Set up techloop string
    wav_play(Ship7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Ship8[] = {"Ship8.wav"}; // Set up techloop string
    wav_play(Ship8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Ship9[] = {"Ship9.wav"}; // Set up techloop string
    wav_play(Ship9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Ship10[] = {"Ship10.wav"}; // Set up techloop string
    wav_play(Ship10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Ship11[] = {"Ship11.wav"}; // Set up techloop string
    wav_play(Ship11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Ship12[] = {"Ship12.wav"}; // Set up techloop string
    wav_play(Ship12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Ship\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }


    int BTFG(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Back to the Future Ghostbusters function\n");
    pause(500);
    if(button4 == 1)
    {
    const char BTFG1[] = {"BTFG1.wav"}; // Set up techloop string
    wav_play(BTFG1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char BTFG2[] = {"BTFG2.wav"}; // Set up techloop string
    wav_play(BTFG2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char BTFG3[] = {"BTFG3.wav"}; // Set up techloop string
    wav_play(BTFG3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char BTFG4[] = {"BTFG4.wav"}; // Set up techloop string
    wav_play(BTFG4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char BTFG5[] = {"BTFG5.wav"}; // Set up techloop string
    wav_play(BTFG5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char BTFG6[] = {"BTFG6.wav"}; // Set up techloop string
    wav_play(BTFG6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char BTFG7[] = {"BTFG7.wav"}; // Set up techloop string
    wav_play(BTFG7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char BTFG8[] = {"BTFG8.wav"}; // Set up techloop string
    wav_play(BTFG8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char BTFG9[] = {"BTFG9.wav"}; // Set up techloop string
    wav_play(BTFG9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char BTFG10[] = {"BTFG10.wav"}; // Set up techloop string
    wav_play(BTFG10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char BTFG11[] = {"BTFG11.wav"}; // Set up techloop string
    wav_play(BTFG11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char BTFG12[] = {"BTFG12.wav"}; // Set up techloop string
    wav_play(BTFG12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in BTFG\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }


    int Cont(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Cont function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Cont1[] = {"Cont1.wav"}; // Set up techloop string
    wav_play(Cont1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Cont2[] = {"Cont2.wav"}; // Set up techloop string
    wav_play(Cont2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Cont3[] = {"Cont3.wav"}; // Set up techloop string
    wav_play(Cont3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Cont4[] = {"Cont4.wav"}; // Set up techloop string
    wav_play(Cont4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Cont5[] = {"Cont5.wav"}; // Set up techloop string
    wav_play(Cont5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Cont6[] = {"Cont6.wav"}; // Set up techloop string
    wav_play(Cont6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Cont7[] = {"Cont7.wav"}; // Set up techloop string
    wav_play(Cont7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Cont8[] = {"Cont8.wav"}; // Set up techloop string
    wav_play(Cont8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Cont9[] = {"Cont9.wav"}; // Set up techloop string
    wav_play(Cont9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Cont10[] = {"Cont10.wav"}; // Set up techloop string
    wav_play(Cont10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Cont11[] = {"Cont11.wav"}; // Set up techloop string
    wav_play(Cont11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Cont12[] = {"Cont12.wav"}; // Set up techloop string
    wav_play(Cont12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Cont\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }




    int Btle(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Btle function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Btle1[] = {"Btle1.wav"}; // Set up techloop string
    wav_play(Btle1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Btle2[] = {"Btle2.wav"}; // Set up techloop string
    wav_play(Btle2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Btle3[] = {"Btle3.wav"}; // Set up techloop string
    wav_play(Btle3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Btle4[] = {"Btle4.wav"}; // Set up techloop string
    wav_play(Btle4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Btle5[] = {"Btle5.wav"}; // Set up techloop string
    wav_play(Btle5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Btle6[] = {"Btle6.wav"}; // Set up techloop string
    wav_play(Btle6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Btle7[] = {"Btle7.wav"}; // Set up techloop string
    wav_play(Btle7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Btle8[] = {"Btle8.wav"}; // Set up techloop string
    wav_play(Btle8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Btle9[] = {"Btle9.wav"}; // Set up techloop string
    wav_play(Btle9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Btle10[] = {"Btle10.wav"}; // Set up techloop string
    wav_play(Btle10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Btle11[] = {"Btle11.wav"}; // Set up techloop string
    wav_play(Btle11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Btle12[] = {"Btle12.wav"}; // Set up techloop string
    wav_play(Btle12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Btle\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }




    int Tank(int button4, int button5, int button6, int button7, int button8, int button9, int button10, int button11, int button12, int button13, int button14, int button15)
    {
    print("Arrived in Tank function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Tank1[] = {"Tank1.wav"}; // Set up techloop string
    wav_play(Tank1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Tank2[] = {"Tank2.wav"}; // Set up techloop string
    wav_play(Tank2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Tank3[] = {"Tank3.wav"}; // Set up techloop string
    wav_play(Tank3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Tank4[] = {"Tank4.wav"}; // Set up techloop string
    wav_play(Tank4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Tank5[] = {"Tank5.wav"}; // Set up techloop string
    wav_play(Tank5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Tank6[] = {"Tank6.wav"}; // Set up techloop string
    wav_play(Tank6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Tank7[] = {"Tank7.wav"}; // Set up techloop string
    wav_play(Tank7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Tank8[] = {"Tank8.wav"}; // Set up techloop string
    wav_play(Tank8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Tank9[] = {"Tank9.wav"}; // Set up techloop string
    wav_play(Tank9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Tank10[] = {"Tank10.wav"}; // Set up techloop string
    wav_play(Tank10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Tank11[] = {"Tank11.wav"}; // Set up techloop string
    wav_play(Tank11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Tank12[] = {"Tank12.wav"}; // Set up techloop string
    wav_play(Tank12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    print("no button pushed in Tank\n");
    pause(500);
    }
    return button4, button5, button6, button7, button8, button9, button10, button11, button12, button13, button14, button15;
    }


    [/php]
  • jazzedjazzed Posts: 11,803
    edited 2014-04-16 18:48
    Hi,

    There are ways to simplify what you have there quite a bit.

    There are some functions that return many variables. That will never work.

    Below is a small rewrite of your program. I made the button variables global so they don't have to be passed to functions. There is room for other improvements. Hope it helps.

    You'll notice some things like this: #define printButtons printf

    In this case printf is smaller than the print function. This requires Compiler "Simple printf" to be checked in the project manager.

    [code]
    /* Final program V1.5
    */
    #include "simpletools.h"
    #include "wavplayer.h"
    #include "simpletools.h"
    #include "servo.h"

    // Declare functions and inputs to those functions


    int button0;
    int button1;
    int button2;
    int button3;
    int button4;
    int button5;
    int button6;
    int button7;
    int button8;
    int button9;
    int button10;
    int button11;
    int button12;
    int button13;
    int button14;
    int button15;


    int Car();
    int Racecar();
    int Semi();
    int Prop();
    int Airl();
    int Jetf();
    int Heli();
    int Train();
    int Enter();
    int Tief();
    int Milf();
    int Ship();
    int BTFG();
    int Cont();
    int Btle();
    int Tank();


    #define printi printf
    #define printButtons printf
    #define printMainInfo //print
    #define printArrived printf


    int main() // main function
    {
    int DO = 22, CLK = 23, DI = 24, CS = 25; // SD I/O pins
    sd_mount(DO, CLK, DI, CS); // Mount SD card


    pause(2000);
    printi("start\n");


    while(1) //infinte loop
    {
    button0 = input(0); //read in buttons
    button1 = input(1);
    button2 = input(2);
    button3 = input(3);
    button4 = input(4);
    button5 = input(5);
    button6 = input(6);
    button7 = input(7);
    button8 = input(8);
    button9 = input(9);
    button10 = input(10);
    button11 = input(11);
    button12 = input(12);
    button13 = input(13);
    button14 = input(14);
    button15 = input(15);


    printButtons("Buttons %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
    button0, button1, button2, button3, button4, button5, button6, button7,
    button8, button9, button10, button11, button12, button13, button14, button15);


    if((button0 == 0) && (button1 == 0) && (button2 == 0) && (button3 == 0))
    {
    printMainInfo("Go to function Car\n");
    Car();
    }
    else if((button0 == 1) && (button1 == 0) && (button2 == 0) && (button3 == 0))
    {
    printMainInfo("Go to funciton Racecar\n");
    Racecar();
    }
    else if((button0 == 0) && (button1 == 1) && (button2 == 0) && (button3 == 0))
    {
    printMainInfo("Go to function Semi\n");
    Semi();
    }
    else if((button0 == 0) && (button1 == 0) && (button2 == 1) && (button3 == 0))
    {
    printMainInfo("Go to function Prop Plane\n");
    Prop();
    }
    else if((button0 == 0) && (button1 == 0) && (button2 == 0) && (button3 == 1))
    {
    printMainInfo("Go to funciton Airliner\n");
    Airl();
    }
    else if((button0 == 1) && (button1 == 1) && (button2 == 0) && (button3 == 0))
    {
    printMainInfo("Go to function Jetfighter\n");
    Jetf();
    }
    else if((button0 == 1) && (button1 == 0) && (button2 == 1) && (button3 == 0))
    {
    printMainInfo("Go to function Helicopter\n");
    Heli();
    }
    else if((button0 == 1) && (button1 == 0) && (button2 == 0) && (button3 == 1))
    {
    printMainInfo("Go to function Train\n");
    Train();
    }
    else if((button0 == 0) && (button1 == 1) && (button2 == 1) && (button3 == 0))
    {
    printMainInfo("Go to function Enterprise\n");
    Enter();
    }
    else if((button0 == 0) && (button1 == 1) && (button2 == 0) && (button3 == 1))
    {
    printMainInfo("Go to function Tie fighter\n");
    Tief();
    }
    else if((button0 == 0) && (button1 == 0) && (button2 == 1) && (button3 == 1))
    {
    printMainInfo("Go to function Millennium Falcon\n");
    Milf();
    }
    else if((button0 == 1) && (button1 == 1) && (button2 == 0) && (button3 == 1))
    {
    printMainInfo("Go to function Ship\n");
    Ship();
    }
    else if((button0 == 1) && (button1 == 0) && (button2 == 1) && (button3 == 1))
    {
    printMainInfo("Go to function Back to the Future and Ghostbusters\n");
    BTFG();
    }
    else if((button0 == 1) && (button1 == 1) && (button2 == 1) && (button3 == 0))
    {
    printMainInfo("Go to function Construction Zone\n");
    Cont();
    }
    else if((button0 == 0) && (button1 == 1) && (button2 == 1) && (button3 == 1))
    {
    printMainInfo("Go to function Battle Sounds\n");
    Btle();
    }
    else if((button0 == 1) && (button1 == 1) && (button2 == 1) && (button3 == 1))
    {
    printMainInfo("Go to function Tank\n");
    Tank();
    }
    else
    {
    printi("ERROR for modes\n");
    }
    }
    }

    int Car()
    {
    printArrived("Arrived in Car function\n");
    pause(5);
    if(button4 == 1)
    {
    const char car1[] = {"car1.wav"}; // Set up techloop string
    wav_play(car1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char car2[] = {"car2.wav"}; // Set up techloop string
    wav_play(car2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char car3[] = {"car3.wav"}; // Set up techloop string
    wav_play(car3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char car4[] = {"car4.wav"}; // Set up techloop string
    wav_play(car4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char car5[] = {"car5.wav"}; // Set up techloop string
    wav_play(car5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char car6[] = {"car6.wav"}; // Set up techloop string
    wav_play(car6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char car7[] = {"car7.wav"}; // Set up techloop string
    wav_play(car7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char car8[] = {"car8.wav"}; // Set up techloop string
    wav_play(car8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char car9[] = {"car9.wav"}; // Set up techloop string
    wav_play(car9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char car10[] = {"car10.wav"}; // Set up techloop string
    wav_play(car10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char car11[] = {"car11.wav"}; // Set up techloop string
    wav_play(car11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5800); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char car12[] = {"car12.wav"}; // Set up techloop string
    wav_play(car12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1150); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    printi("no button pushed in Car\n");
    pause(500);
    }
    return 0;
    }

    int Racecar()
    {
    printArrived("Arrived in Racecar function\n");
    pause(500);
    if(button4 == 1)
    {
    const char rcar1[] = {"rcar1.wav"}; // Set up techloop string
    wav_play(rcar1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(825); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char rcar2[] = {"rcar2.wav"}; // Set up techloop string
    wav_play(rcar2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char rcar3[] = {"rcar3.wav"}; // Set up techloop string
    wav_play(rcar3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(2300); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char rcar4[] = {"rcar4.wav"}; // Set up techloop string
    wav_play(rcar4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char rcar5[] = {"rcar5.wav"}; // Set up techloop string
    wav_play(rcar5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(6000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char rcar6[] = {"rcar6.wav"}; // Set up techloop string
    wav_play(rcar6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1300); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char rcar7[] = {"rcar7.wav"}; // Set up techloop string
    wav_play(rcar7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char rcar8[] = {"rcar8.wav"}; // Set up techloop string
    wav_play(rcar8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char rcar9[] = {"rcar9.wav"}; // Set up techloop string
    wav_play(rcar9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(9100); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char rcar10[] = {"rcar10.wav"}; // Set up techloop string
    wav_play(rcar10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(2080); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char rcar11[] = {"rcar11.wav"}; // Set up techloop string
    wav_play(rcar11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char rcar12[] = {"rcar12.wav"}; // Set up techloop string
    wav_play(rcar12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1500); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    printi("no button pushed in Rcar\n");
    pause(500);
    }
    return 0;
    }



    int Semi()
    {
    printArrived("Arrived in Semi function\n");
    pause(500);
    if(button4 == 1)
    {
    const char semi1[] = {"semi1.wav"}; // Set up techloop string
    wav_play(semi1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(3000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char semi2[] = {"semi2.wav"}; // Set up techloop string
    wav_play(semi2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char semi3[] = {"semi3.wav"}; // Set up techloop string
    wav_play(semi3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(6000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char semi4[] = {"semi4.wav"}; // Set up techloop string
    wav_play(semi4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(8000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char semi5[] = {"semi5.wav"}; // Set up techloop string
    wav_play(semi5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char semi6[] = {"semi6.wav"}; // Set up techloop string
    wav_play(semi6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char semi7[] = {"semi7.wav"}; // Set up techloop string
    wav_play(semi7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1500); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char semi8[] = {"semi8.wav"}; // Set up techloop string
    wav_play(semi8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(2200); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char semi9[] = {"semi9.wav"}; // Set up techloop string
    wav_play(semi9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1100); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char semi10[] = {"semi10.wav"}; // Set up techloop string
    wav_play(semi10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char semi11[] = {"semi11.wav"}; // Set up techloop string
    wav_play(semi11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char semi12[] = {"semi12.wav"}; // Set up techloop string
    wav_play(semi12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    printi("no button pushed in Semi\n");
    pause(500);
    }
    return 0;
    }



    int Prop()
    {
    printArrived("Arrived in Prop Plane function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Prop1[] = {"Prop1.wav"}; // Set up techloop string
    wav_play(Prop1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(2500); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Prop2[] = {"Prop2.wav"}; // Set up techloop string
    wav_play(Prop2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(6600); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Prop3[] = {"Prop3.wav"}; // Set up techloop string
    wav_play(Prop3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(2200); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Prop4[] = {"Prop4.wav"}; // Set up techloop string
    wav_play(Prop4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Prop5[] = {"Prop5.wav"}; // Set up techloop string
    wav_play(Prop5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(7300); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Prop6[] = {"Prop6.wav"}; // Set up techloop string
    wav_play(Prop6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5200); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Prop7[] = {"Prop7.wav"}; // Set up techloop string
    wav_play(Prop7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Prop8[] = {"Prop8.wav"}; // Set up techloop string
    wav_play(Prop8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Prop9[] = {"Prop9.wav"}; // Set up techloop string
    wav_play(Prop9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(7300); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Prop10[] = {"Prop10.wav"}; // Set up techloop string
    wav_play(Prop10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Prop11[] = {"Prop11.wav"}; // Set up techloop string
    wav_play(Prop11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Prop12[] = {"Prop12.wav"}; // Set up techloop string
    wav_play(Prop12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    printi("no button pushed in Prop Plane\n");
    pause(500);
    }
    return 0;
    }



    int Airl()
    {
    printArrived("Arrived in Airliner function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Airl1[] = {"Airl1.wav"}; // Set up techloop string
    wav_play(Airl1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(4500); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Airl2[] = {"Airl2.wav"}; // Set up techloop string
    wav_play(Airl2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(4000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Airl3[] = {"Airl3.wav"}; // Set up techloop string
    wav_play(Airl3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(7000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Airl4[] = {"Airl4.wav"}; // Set up techloop string
    wav_play(Airl4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(4200); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Airl5[] = {"Airl5.wav"}; // Set up techloop string
    wav_play(Airl5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Airl6[] = {"Airl6.wav"}; // Set up techloop string
    wav_play(Airl6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1250); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Airl7[] = {"Airl7.wav"}; // Set up techloop string
    wav_play(Airl7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(900); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Airl8[] = {"Airl8.wav"}; // Set up techloop string
    wav_play(Airl8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(3000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Airl9[] = {"Airl9.wav"}; // Set up techloop string
    wav_play(Airl9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(9000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Airl10[] = {"Airl10.wav"}; // Set up techloop string
    wav_play(Airl10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(8000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Airl11[] = {"Airl11.wav"}; // Set up techloop string
    wav_play(Airl11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(2230); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Airl12[] = {"Airl12.wav"}; // Set up techloop string
    wav_play(Airl12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    printi("no button pushed in Airl\n");
    pause(500);
    }
    return 0;
    }


    int Jetf()
    {
    printArrived("Arrived in Jetf function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Jetf1[] = {"Jetf1.wav"}; // Set up techloop string
    wav_play(Jetf1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Jetf2[] = {"Jetf2.wav"}; // Set up techloop string
    wav_play(Jetf2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Jetf3[] = {"Jetf3.wav"}; // Set up techloop string
    wav_play(Jetf3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Jetf4[] = {"Jetf4.wav"}; // Set up techloop string
    wav_play(Jetf4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Jetf5[] = {"Jetf5.wav"}; // Set up techloop string
    wav_play(Jetf5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Jetf6[] = {"Jetf6.wav"}; // Set up techloop string
    wav_play(Jetf6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Jetf7[] = {"Jetf7.wav"}; // Set up techloop string
    wav_play(Jetf7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Jetf8[] = {"Jetf8.wav"}; // Set up techloop string
    wav_play(Jetf8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Jetf9[] = {"Jetf9.wav"}; // Set up techloop string
    wav_play(Jetf9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Jetf10[] = {"Jetf10.wav"}; // Set up techloop string
    wav_play(Jetf10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Jetf11[] = {"Jetf11.wav"}; // Set up techloop string
    wav_play(Jetf11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Jetf12[] = {"Jetf12.wav"}; // Set up techloop string
    wav_play(Jetf12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    printi("no button pushed in Jetf\n");
    pause(500);
    }
    return 0;
    }



    int Heli()
    {
    printArrived("Arrived in Helicopter function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Heli1[] = {"Heli1.wav"}; // Set up techloop string
    wav_play(Heli1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Heli2[] = {"Heli2.wav"}; // Set up techloop string
    wav_play(Heli2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Heli3[] = {"Heli3.wav"}; // Set up techloop string
    wav_play(Heli3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Heli4[] = {"Heli4.wav"}; // Set up techloop string
    wav_play(Heli4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Heli5[] = {"Heli5.wav"}; // Set up techloop string
    wav_play(Heli5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Heli6[] = {"Heli6.wav"}; // Set up techloop string
    wav_play(Heli6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Heli7[] = {"Heli7.wav"}; // Set up techloop string
    wav_play(Heli7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Heli8[] = {"Heli8.wav"}; // Set up techloop string
    wav_play(Heli8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Heli9[] = {"Heli9.wav"}; // Set up techloop string
    wav_play(Heli9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Heli10[] = {"Heli10.wav"}; // Set up techloop string
    wav_play(Heli10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Heli11[] = {"Heli11.wav"}; // Set up techloop string
    wav_play(Heli11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Heli12[] = {"Heli12.wav"}; // Set up techloop string
    wav_play(Heli12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    printi("no button pushed in Heli\n");
    pause(500);
    }
    return 0;
    }


    int Train()
    {
    printArrived("Arrived in Train function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Train1[] = {"Train1.wav"}; // Set up techloop string
    wav_play(Train1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Train2[] = {"Train2.wav"}; // Set up techloop string
    wav_play(Train2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Train3[] = {"Train3.wav"}; // Set up techloop string
    wav_play(Train3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Train4[] = {"Train4.wav"}; // Set up techloop string
    wav_play(Train4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Train5[] = {"Train5.wav"}; // Set up techloop string
    wav_play(Train5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Train6[] = {"Train6.wav"}; // Set up techloop string
    wav_play(Train6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Train7[] = {"Train7.wav"}; // Set up techloop string
    wav_play(Train7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Train8[] = {"Train8.wav"}; // Set up techloop string
    wav_play(Train8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Train9[] = {"Train9.wav"}; // Set up techloop string
    wav_play(Train9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Train10[] = {"Train10.wav"}; // Set up techloop string
    wav_play(Train10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Train11[] = {"Train11.wav"}; // Set up techloop string
    wav_play(Train11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Train12[] = {"Train12.wav"}; // Set up techloop string
    wav_play(Train12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    printi("no button pushed in Train\n");
    pause(500);
    }
    return 0;
    }



    int Enter()
    {
    printArrived("Arrived in Enterprise function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Enter1[] = {"Enter1.wav"}; // Set up techloop string
    wav_play(Enter1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Enter2[] = {"Enter2.wav"}; // Set up techloop string
    wav_play(Enter2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Enter3[] = {"Enter3.wav"}; // Set up techloop string
    wav_play(Enter3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Enter4[] = {"Enter4.wav"}; // Set up techloop string
    wav_play(Enter4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Enter5[] = {"Enter5.wav"}; // Set up techloop string
    wav_play(Enter5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Enter6[] = {"Enter6.wav"}; // Set up techloop string
    wav_play(Enter6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Enter7[] = {"Enter7.wav"}; // Set up techloop string
    wav_play(Enter7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Enter8[] = {"Enter8.wav"}; // Set up techloop string
    wav_play(Enter8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Enter9[] = {"Enter9.wav"}; // Set up techloop string
    wav_play(Enter9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Enter10[] = {"Enter10.wav"}; // Set up techloop string
    wav_play(Enter10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Enter11[] = {"Enter11.wav"}; // Set up techloop string
    wav_play(Enter11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Enter12[] = {"Enter12.wav"}; // Set up techloop string
    wav_play(Enter12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    printi("no button pushed in Enter\n");
    pause(500);
    }
    return 0;
    }



    int Tief()
    {
    printArrived("Arrived in Tie fighter function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Tief1[] = {"Tief1.wav"}; // Set up techloop string
    wav_play(Tief1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Tief2[] = {"Tief2.wav"}; // Set up techloop string
    wav_play(Tief2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Tief3[] = {"Tief3.wav"}; // Set up techloop string
    wav_play(Tief3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Tief4[] = {"Tief4.wav"}; // Set up techloop string
    wav_play(Tief4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Tief5[] = {"Tief5.wav"}; // Set up techloop string
    wav_play(Tief5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Tief6[] = {"Tief6.wav"}; // Set up techloop string
    wav_play(Tief6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Tief7[] = {"Tief7.wav"}; // Set up techloop string
    wav_play(Tief7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Tief8[] = {"Tief8.wav"}; // Set up techloop string
    wav_play(Tief8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Tief9[] = {"Tief9.wav"}; // Set up techloop string
    wav_play(Tief9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char Tief10[] = {"Tief10.wav"}; // Set up techloop string
    wav_play(Tief10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char Tief11[] = {"Tief11.wav"}; // Set up techloop string
    wav_play(Tief11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char Tief12[] = {"Tief12.wav"}; // Set up techloop string
    wav_play(Tief12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    printi("no button pushed in Tie fighter\n");
    pause(500);
    }
    return 0;
    }



    int Milf()
    {
    printArrived("Arrived in Millenium falcon function\n");
    pause(500);
    if(button4 == 1)
    {
    const char Milf1[] = {"Milf1.wav"}; // Set up techloop string
    wav_play(Milf1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char Milf2[] = {"Milf2.wav"}; // Set up techloop string
    wav_play(Milf2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char Milf3[] = {"Milf3.wav"}; // Set up techloop string
    wav_play(Milf3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char Milf4[] = {"Milf4.wav"}; // Set up techloop string
    wav_play(Milf4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char Milf5[] = {"Milf5.wav"}; // Set up techloop string
    wav_play(Milf5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char Milf6[] = {"Milf6.wav"}; // Set up techloop string
    wav_play(Milf6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char Milf7[] = {"Milf7.wav"}; // Set up techloop string
    wav_play(Milf7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char Milf8[] = {"Milf8.wav"}; // Set up techloop string
    wav_play(Milf8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char Milf9[] = {"Milf9.wav"}; // Set up techloop string
    wav
  • gwtthrgwtthr Posts: 30
    edited 2014-04-18 08:03
    Thanks for the help. :thumb: It took me a minute to find the Compiler box to check because my view wasn't set up to see it, but I'm on my way to a final version of the code.

    Would there be a way to remove all the repetitive functions from the code by using a string variable set to whatever mode the toy is in? If this was Excel I'd call it concatenate, where it takes numbers and string and puts them together for you. For example see below and I have comments/questions in the code:

    [php]
    /*
    Final program V5.0
    */

    #include "simpletools.h"
    #include "wavplayer.h"
    #include "servo.h"

    // Declare functions and inputs to those functions




    int button0;
    int button1;
    int button2;
    int button3;
    int button4;
    int button5;
    int button6;
    int button7;
    int button8;
    int button9;
    int button10;
    int button11;
    int button12;
    int button13;
    int button14;
    int button15;
    string x; // I'm not sure how to call out a string




    int car(); // If I don't have functions any more, do I need these?
    int Racecar();
    int Semi();
    int Prop();
    int Airl();
    int Jetf();
    int Heli();
    int Train();
    int Enter();
    int Tief();
    int Milf();
    int Ship();




    #define printi printf
    #define printButtons printf
    #define printMainInfo
    #define printArrived printf




    int main() // main function
    {
    int DO = 22, CLK = 23, DI = 24, CS = 25; // SD I/O pins
    sd_mount(DO, CLK, DI, CS); // Mount SD xd




    pause(2000);
    printi("start\n");




    while(1) //infinte loop
    {
    button0 = input(0); //read in buttons
    button1 = input(1);
    button2 = input(2);
    button3 = input(3);
    button4 = input(4);
    button5 = input(5);
    button6 = input(6);
    button7 = input(7);
    button8 = input(8);
    button9 = input(9);
    button10 = input(10);
    button11 = input(11);
    button12 = input(12);
    button13 = input(13);
    button14 = input(14);
    button15 = input(15);




    printButtons("Buttons %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
    button0, button1, button2, button3, button4, button5, button6, button7,
    button8, button9, button10, button11, button12, button13, button14, button15);




    if((button0 == 0) && (button1 == 0) && (button2 == 0) && (button3 == 0))
    {
    printMainInfo("x mode\n");
    x = Car;
    }
    else if((button0 == 1) && (button1 == 0) && (button2 == 0) && (button3 == 0))
    {
    printMainInfo("Racex mode\n");
    x= Racecar;
    }
    else if((button0 == 0) && (button1 == 1) && (button2 == 0) && (button3 == 0))
    {
    printMainInfo("Go to function Semi\n");
    x=Semi;
    }
    else if((button0 == 0) && (button1 == 0) && (button2 == 1) && (button3 == 0))
    {
    printMainInfo("Go to function Prop Plane\n");
    x=Prop;
    }
    else
    {
    printi("ERROR for modes\n");
    }


    // The code just puts in the sting name for variable x in the program no longer uses mulitple functions


    printArrived("Arrived in ", x variable name here, "function\n"); // Not sure how to get the variable to display inside the print
    pause(5);
    if(button4 == 1)
    {
    const char x1[] = {"x varaible name here, "1.wav"}; // Set up techloop string
    wav_play(x1); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button5 == 1)
    {
    const char x2[] = {"x2.wav"}; // Set up techloop string
    wav_play(x2); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button6 == 1)
    {
    const char x3[] = {"x3.wav"}; // Set up techloop string
    wav_play(x3); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button7 == 1)
    {
    const char x4[] = {"x4.wav"}; // Set up techloop string
    wav_play(x4); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button8 == 1)
    {
    const char x5[] = {"x5.wav"}; // Set up techloop string
    wav_play(x5); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button9 == 1)
    {
    const char x6[] = {"x6.wav"}; // Set up techloop string
    wav_play(x6); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button10 == 1)
    {
    const char x7[] = {"x7.wav"}; // Set up techloop string
    wav_play(x7); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button11 == 1)
    {
    const char x8[] = {"x8.wav"}; // Set up techloop string
    wav_play(x8); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button12 == 1)
    {
    const char x9[] = {"x9.wav"}; // Set up techloop string
    wav_play(x9); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button13 == 1)
    {
    const char x10[] = {"x10.wav"}; // Set up techloop string
    wav_play(x10); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5000); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button14 == 1)
    {
    const char x11[] = {"x11.wav"}; // Set up techloop string
    wav_play(x11); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(5800); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else if(button15 == 1)
    {
    const char x12[] = {"x12.wav"}; // Set up techloop string
    wav_play(x12); // Pass to wav player
    wav_volume(6); // Adjust volume
    pause(1150); // Play for 5 s
    wav_stop(); // Stop playing
    }
    else
    {
    printi("no button pushed in x\n");
    pause(500);
    }


    }
    }


    [/php]

    The code would be much shorter, but I don't have the experience to code it. Help!
  • gwtthrgwtthr Posts: 30
    edited 2014-04-18 08:08
    I've noticed a flaw in the above code. If there are no unique functions in the code, then the servos will do the same thing for each button, in each mode. Hmmm....

    But that is shorter code!
  • jazzedjazzed Posts: 11,803
    edited 2014-04-18 11:15
    Hi.

    As noted there is lots of redundancy in your code.

    If you want to pass an assembled string to a function, do something like this:
    #include "simpletools.h"
    
    void playwav(char *wavfile)
    {
      wav_play(wavfile);                             // Pass to wav player
      wav_volume(6);                                  // Adjust volume
      pause(5000);                                    // Play for 5 s
      wav_stop();                                     // Stop playing
    }
    
    int main()
    {
      char buffer[256];
    
      sprint(buffer, "%s.txt", "hello"); // sprint is like the standard C function sprintf.
      playwav(buffer);
    
      return 0;
    }
    


    Your button code is bigger than necessary. The input() function can only return one input state at a time. Try something like this instead.
    // 8 wave files ... associates fileN with entryN
    #define WAVFILE_COUNT 8
    char *wavfiles[WAVFILE_COUNT] = {
      "file0.wav",
      "file1.wav",
      "file2.wav",
      "file3.wav",
      "file4.wav",
      "file5.wav",
      "file6.wav",
      "file7.wav",
    };
    
    // use another array to map different pins to different files ... optional
    int pinmap[WAVFILE_COUNT] = {
      3, 2, 1, 0, 7, 6, 5, 4
    };
    
    void doButtons() {
      int n = 0;
      int buttons = INA; // very simplified button reader. no debouncing, etc....
      int filenumber = 0;
    
      for(n = 0; n < WAVFILE_COUNT; n++) {
        filenumber = pinmap[n];
        if(buttons & (1 << n)) {
          playwav(wavefiles[n]);
          //playwav(wavefiles[filenumber]); // optional
        }
    
      }
    }
    
    That example may seem complicated at first, but if you study it a bit, you'll find that it is very flexible.
  • gwtthrgwtthr Posts: 30
    edited 2014-04-22 09:00
    A little more progress...

    IMG_7397[1].JPG
    640 x 480 - 118K
  • jazzedjazzed Posts: 11,803
    edited 2014-04-22 10:37
    Looks nice.

    How did you choose the "Airforce Gray"?

    Any luck with your code?
  • gwtthrgwtthr Posts: 30
    edited 2014-04-22 12:17
    Thanks.

    I went with the gray for three reasons. First, it was the most neutral color considering this toy covers multiple modes of transportation. Second, I liked styling of the Millennium Falcon console from Star Wars (fullscalefalcon.com). Third, I had gray primer on hand.

    Unfortunately, I haven't had too much luck with the code. But I haven't had much more than a couple evenings to look at it since you gave me your first set of suggestions. I just finished the wiring of the console only hours after posting that last picture. I'll be chasing down wiring issues tonight now that it's together. I noticed at least one wire pulled out of position when I put the final panel on. Hopefully there are no others.
  • infoinfo Posts: 31
    edited 2014-04-22 16:59
    I always find programming the hard part of a project. I can use soldering iron and read datasheet, but I don't understand programming languages that use symbols and brackets as a language. Assembly and Basic are the only languages I'm able to understand.

    I tried to learn starting from the real beginning "A step-by-step tutorial for new users".


    Open the Propeller Tool and type in the program listed below.

    CON

    _clkmode=xtal1+pll16x
    _xinfreq=5_000_000

    OBJ

    term:"PC_Interface"

    PUB Main

    term.start(31,30)

    repeat
    term.str(string("Hello World",13))


    By now you are beginning to see just how easy it is to program the Propeller microprocessor.


    I"M SORRY, BUT I DON"T SEE HOW EASY it is to program the Propeller microprocessor.
    Not one single line of the example code was described and explained, and I didn't find anywhere in Propeller Manual or Datasheet any reference to "term", "start", reason for brackets and the numbers 31,30. Only on the schema I found pins 31 and 30 relating to serial port.

    I read hundreds of pages and I still have no clue what does the program snippet do, while I think it sends a string "Hello World" out on serial port, I just can't figure out how. So I can't write programs when I don't understand how they work. My programs may work, but I wouldn't be able to tell you how.

    I just feel whoever wrote the tutorial was not qualified to do so. Just like Chinese electronics. They steal our designs, manufacture and sell copycats, but can't provide user's manual or datasheet because they have no clue what they stole and copied.

    Yeah, I'm not the brightest bulb that's for sure. I tried to learn other high level languages from books on the lowest level "Javascript for Dummies", etc. Similar experience. Code snippets without explanation. I don't know who is the bigger dummie. The writer who assumes you can read mind, or I'm the dummie since I never learned to read minds.
  • gwtthrgwtthr Posts: 30
    edited 2014-04-22 19:07
    One more update...


    Wiring: I went the easy route. I bought the shift registers, but never used them.
    DSC_0521.jpg



    Here is the console almost complete. I need to mount the steering wheel, create a second set of gauges (blue servos left of volmeter), and finalize code. Fortunatley, I do have working code that is adeqaute for now.
    DSC_0531.jpg


    Here is a look at the organized chaos underneath. As you can see the right hand side of the console is full of dummy switches. I've got to leave something up to the imagination or else I'm building a video game.
    DSC_0532.jpg
    1024 x 678 - 127K
    1024 x 678 - 77K
    1024 x 678 - 78K
  • jazzedjazzed Posts: 11,803
    edited 2014-04-22 19:32
    I like Airforce gray! I meant to say "where did you get it?"

    It's almost as nice as quicksilver metallic:

    corvette20025451.jpg
  • infoinfo Posts: 31
    edited 2014-04-22 20:05
    There is a way to save i/o pins on Propeller. The Propeller needs 4 pins to boot. 2 for serial port and 2 for i2c eeprom. All other pins are available. Adding MPC23008 i2c expander adds 8 pins for input/output. You can add several of these expanders and never use a pin on the Propeller. Since you have the eeprom at i2c address 0, you have to write i2c code anyway and save a pin you would need to use for shift register.
  • gwtthrgwtthr Posts: 30
    edited 2014-04-24 17:45
    jazzed wrote: »
    I like Airforce gray! I meant to say "where did you get it?"

    It's almost as nice as quicksilver metallic:

    corvette20025451.jpg

    It's just a standard Rustoleum Automotive primer in a spray can. Available at Wal-mart.

    I've got that color on my Impala, but I think it's called Silver Ice Metallic. I really prefer Pewter myself. It's gold in some light, and silver in other.

    Camaro 003.jpg
    :lol:
    1024 x 768 - 106K
  • jazzedjazzed Posts: 11,803
    edited 2014-04-25 08:47
    Any progress with your code?

    Hopefully some of the examples I gave are usable.
  • gwtthrgwtthr Posts: 30
    edited 2014-04-26 18:53
    I found an hour to look at code on Thursday, but with that limited amount of time I couldn't decipher your code. I just need more time with it. Until then, my first attempt at code will work for now.

    I did finish the console.

    DSC_0002.jpg
    DSC_0001.jpg
    DSC_0003.jpg
    1024 x 678 - 88K
    1024 x 678 - 88K
    1024 x 678 - 96K
Sign In or Register to comment.