0

Play spaceship control panel
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Play spaceship control panel

by diydad on Sat Feb 02, 2019 5:20 pm

Hello

Trying to make a spaceship control panel (v2.0) for my kids.

I already made a sound board with the audio fx and some separate LEDs and switches. Now we would really like to make role play control panel that will have some logic.

For example, switches operated in a different order, or different quantity producing different outcomes e.g: LEDS, Audio maybe even a tweet or a action to a phone etc

As a starter for 10 could some nice person just even indicate what extra hardware I would need, so I can go from there.

I have the audio fx, amp and a speaker.....

No electronics or programming exp other than this !!!

Thanks in advance,
Alex

diydad
 
Posts: 2
Joined: Sat Feb 02, 2019 5:13 pm

Re: Play spaceship control panel

by andrewa on Sat Feb 02, 2019 5:29 pm

For role-playing, or other such stuff, you might want to see who has done things in the escape room world, and piggyback on that.

For example, setting a code/combo lock based on logic. There might be some open source stuff out there.

As far as sensors/actuators go, the sky is the limit. If you have an old iPhone or Android, you could hook it up as part of the control panel, and have BLE devices that do things, or read temperatures, light intensities, etc.

andrewa
 
Posts: 134
Joined: Mon Oct 19, 2009 9:53 pm

Re: Play spaceship control panel

by adafruit_support_mike on Sun Feb 03, 2019 3:01 am

You'll probably find it easiest to add the effects you want using a microcontroller.

The idea of having different patterns of input do different things involves a concept known in computing as 'state'.. basically, "the path you took to get where you are now, matters." There's a category of programmable devices and/or code called 'state machines' which implement that kind of behavior.

Programming languages provide lots of different ways to make state machines, but once you know the general pattern, they all start to look familiar. The basic trick is to break things down into items called STATES, INPUTS, and TRANSITIONS (traditionally capitalized because they're important variables in code).

A STATE is just an identifier that records where you are now. We generally use names when designing a state machine, but convert the names to numbers when writing the code.

An INPUT is something that the state machine responds to. It might be a number in a combination, a button press in a control sequence, or a character in a string of text. The main idea is that we use the input to decide what to do next.

Those decisions are the TRANSITIONS, and they all have the same form: "if I'm in state X, and I receive input A, go to state Y." One state can have several different transitions for different kinds of input:

- If I'm in state X, and I receive input A, go to state Y
- If I'm in state X, and I receive input B, go to state Z
- If I'm in state X, and I receive input C, go to state W

and so on. The set of all transitions for every state is called the 'transition table' (traditionally named TRANS).

One way to write code for a state machine is to use switch() functions:

Code: Select all | TOGGLE FULL SIZE
void state_X () {
    int INPUT = get_input();
   
    switch ( INPUT ) {
        case A :
            state_Y();
            break;
        case B :
            state_Z();
            break;
        case C :
            state_W();
            break;
    }
}
which says pretty much the same thing as the list of transitions above, just in programming language.

The main idea is that each state knows what to do with its own input, and the machine moves from one state to another in response to the input. The important side effect is you can only get to one state from another, and the machine had to see a specific input for that to happen. Each state ends up meaning, "the machine has seen a specific pattern of input so far".. an extremely useful idea.

Once you get familiar with the basic ideas of state machines and state transitions, you can make each state do things. Experience shows that it's generally most useful to make the actions happen like so:

Code: Select all | TOGGLE FULL SIZE
void state_X () {
    action_for_entering_state_X();
   
    int INPUT = get_input();
   
    action_for_leaving_state_X();

    switch ( INPUT ) {
        case A :
            action_for_X_to_Y_transition();
            state_Y();
            break;
        case B :
            action_for_X_to_Z_transition();
            state_Z();
            break;
        case C :
            action_for_X_to_W_transition();
            state_W();
            break;
    }
}
You aren't required to use all of them (or any of them), but almost any statement of the form, "when the user does this, I want the machine to do that" will fit comfortably into one of those slots.

Don't assume you have to understand all of that in detail right now. The take-away ideas are, "yes, what you want to do is possible" and "there's a well-known way to do it." The technique happens to be a powerful system built from simple pieces, and and those tend to be hard to invent from scratch.

adafruit_support_mike
 
Posts: 58843
Joined: Thu Feb 11, 2010 2:51 pm

Re: Play spaceship control panel

by diydad on Sun Feb 03, 2019 5:50 am

Thank you so much for this reply. We are very grateful.

Which micro controller would be best for this application?

trinket?
arduino?
Pi?
microbit?
other....?

any suggesting would be really great !

diydad
 
Posts: 2
Joined: Sat Feb 02, 2019 5:13 pm

Re: Play spaceship control panel

by adafruit_support_mike on Mon Feb 04, 2019 1:44 am

If you're just getting started, the Metro 328 would be a good choice:

https://www.adafruit.com/product/2488

It's compatible with the Arduino Uno, which is probably the most well-known microcontroller board for hobbyists. You can find tons of existing code and information online, including our 'Learn Arduino' series of turorials over in the Learning System:

https://learn.adafruit.com/adafruit-ard ... on-1-blink

They start with the most basic information about connecting the board to a computer, what kind of software you need, and how to get some simple results, like making an LED blink. Then the tutorials work through a set of jobs that tend to come up in most projects, like reading input from buttons.

If you want some additional parts to connect to the Metro, we have a starter pack that includes the Metro, a power supply and USB cable, some LEDs, a breadboard (used to build test circuits), jumper wires, and so on:

https://www.adafruit.com/product/3345

adafruit_support_mike
 
Posts: 58843
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.