How to include user input to remotely control 5 motors and LED

I am relatively new, and I am attempting to remotely control a few motors and an LED through my Spark Core by using an input through my computer. I would like it to function as a video game, where, for example, you could press the key “A” on the keyboard of a laptop and a motor would in return. The issue is there is no type of running program that occurs while the firmware is being run. How would I go about doing this and is there any example code that someone has been able to make that could solve my issue?

You probably want to be calling Spark functions to control the motors and LED. There are various ways to do this from the computer end. What kind of laptop do you have, and what programming experience do you have? It’s not clear what you mean by, “there is no type of running program that occurs while the firmware is being run”.

1 Like

This might also be interesting:

I have a macBook however I am not able to download any new software because the computer is supplied through the school. I have processing preloaded on it and through that can create and run java programs. Do you know of any online programs compatible with the spark core that would enable me to do what I want?

And by “there is no type of running program that occurs while the firmware is being run” what I mean is no automatic window that appears on the computer that would allow for user input as the firmware of the Core is being run. Loosely comparing it to java when the program runs a window of said program appears which allows the user to input data and commands.

Have a look at Examples on the Spark documentation page. There is an example, “Control LEDs over the 'net”, that will show you the basics of how to control an LED from a browser.

How fast would you need this to run, and would the control happen locally (on the same network) or externally?

preferably externally cause coolness. And by having it run like a video game i mean like having the controls similar to those that can be found on and online game. I have no intension of including any types of graphics or things of that nature

With “how fast” I was thinking more of response times. Function calls are generally limited to 1p/s, and a maximum of about 3p/s due to network time. Were you to do this locally, you could achieve greater speeds since you could control it directly, which is much faster.
I do believe function calls are easiest in this case, since they require no extra software on your computer. You should be able to make a website which accepts keyboard input fairly easily, I think.

So looking on the “Control LEDs over the 'net” example and while sending in the command by pressing the submit button it navigates to a different page as a confirmation. I’ve been looking through the code and haven’t been able to come up with a way to stop this. Also is there a way of making it so I do not have to press a submit button to push the data out? For example, when the “Turn the LED on” option is chosen it will automatically turn on the LED?

With a tiny bit of JavaScript, if should be possible to make it react to keyboard pressed without reloading the page. Try a quick google for “keyboard events” and you should see some example code for the key pressing part.
For sending the requests, you could use the JavaScript library, which should be relatively straight forward as well.