Help controlling a light from PC

I have a arduino mega that has the standard firmata software on it. I have pin 2 connected to a relay which turns on and off a light. If I use the firmata test software this works fine. I can turn on (high) pin 2 and the light turns on. turn it off (low) and it turns off. so circuit wise and software wise this works fine. now for my issue. I need to find some way to control it from a PC from something like a command line. I need to control this from an elgato streamdeck which of I can create a batch file that will turn on and off the light then I can have that streamdeck run the batch file. I have scoured the net and cannot find a simple way to do this. I have reached out to Elgato and they are telling me they do not know how to control an arduino but I'm sure this must be fairly simple

In general your batch file has to find the Arduino COM port on the PC and then send a command (character...) to it. The Arduino will receive that command from Serial and should act as commanded. This may be a matter of the firmata software which I don't know.

A PC control software like Processing (or firmata?) is fine for immediate use but hell if you want to use a different program or batch on the PC. I'd get rid of firmata on the Arduino and use Serial.available() and Serial.read() for receiving a command from the PC.

I am open to any and all ways to accomplish this. Bottom line I just need to press a button on the streamdeck and have the light come on without having to go to my boss and tell him we need to spend more money

Get rid of Firmata and be happy with the Arduino framework. See the IDE examples for controlling digital outputs from input of Serial.

The only and well known problem is the determination of the COM port used by the Arduino. You'll find applicable code for many programming languages.

how do I install the arduino framework? I do not see it in the arduino software. as for programming languages I would be totally lost in what to look for. The only thing I couled do a serch for would be someone on the internet told me to look for programming language which of course would sned me down such a deep dark hole I would never escape :slight_smile:

Can you please expand on your TUTORIAL ?

1 Like

It's just the IDE. What @DrDiettrich is referring to is to write your own sketch that handles the serial input.

Be aware that there can be a pitfall when opening a serial connection with a Mega; it will reset which takes a few seconds before your sketch starts running. I think that you can prevent this when using a board with native USB (e.g. a Leonardo, Micro) and it can be prevented when you hack the Mega.

Ask them if they have an API to control of external devices via serial (or network); it might already be in the documentation that you have; I could not immediately find documentation on their website.

Your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem :wink:

[quote="sterretje, post:7, topic:987315, full:true"]

It's just the IDE. What @DrDiettrich is referring to is to write your own sketch that handles the serial input.[/quote] that is kind of where I need help. I don't know a thing about programming the arduino

[quote="sterretje, post:7, topic:987315, full:true"]

Ask them if they have an API to control of external devices via serial (or network); it might already be in the documentation that you have; I could not immediately find documentation on their website.[quote]the only thing they offer is to point me in the direction of their third party plugins but from what I see all their 3rd party plugins are all based around controlling things like phillips hue

sorry about that :slight_smile:

Time to learn :wink: Do you know anything about programming?

  1. The blink example in the IDE can give you the basics how to switch a led on and off.
  2. Robin's Serial Input Basics - updated might get you in the right direction when it comes to serial communication.
  3. To take a decision based on e.g. received data: if - Arduino Reference

Do I know anything about programming? Not really. The entire reason I went the Arduino route for this is We are trying to setup a tally light to be used for vmix and they show the Arduino is capable of doing this. The instructions seam pretty straight forward and it was a low cost solution. unfortunately though the arduino failed to work and the only support I got from vmix was to buy a professional tally unit! now I am stuck trying to figure out a solution for this/ I know that the stream deck that we are using is capable of running a batch program so I figured that might be a simple solution however I cannot find a way to trigger the light through a command line that I can plug into the streamdeck

You can ask for assistance in this forum section.

Do YOU know how to run the batch file from stream deck?

If you don't know how to communicate on a command prompt, command prompt send data to serial port - Google Search. This one might have a reasonable explanation: Simple command line trick for sending characters to a serial port in Windows | ad hocumentation • n. fast documentation of ideas and solutions..

This would be a possible Arduino code; if it receives the character '1' the builtin led will switch on, if it receives = '0' the builtin led will switch off and any other received character will be ignored.

const uint8_t ledPin = LED_BUILTIN;

void setup()
{
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
}

void loop()
{
  // if there is data received
  if (Serial.available() > 0)
  {
    // read it
    char ch = Serial.read();
    // action it
    if (ch == '1')
    {
      digitalWrite(ledPin, HIGH);
    }
    else if (ch == '0')
    {
      digitalWrite(ledPin, LOW);
    }
    else
    {
      // ignore
    }
  }
}

The command line

C:\Users\sterretje>mode com5 baud=115200 parity=n data=8

Status for device COM5:
-----------------------
    Baud:            115200
    Parity:          None
    Data Bits:       8
    Stop Bits:       1
    Timeout:         ON
    XON/XOFF:        OFF
    CTS handshaking: OFF
    DSR handshaking: OFF
    DSR sensitivity: OFF
    DTR circuit:     OFF
    RTS circuit:     OFF


C:\Users\sterretje>echo "1" > COM5

C:\Users\sterretje>echo "0" > COM5

C:\Users\sterretje>echo "a" > COM5

C:\Users\sterretje>

It does not even reset the Arduino which is probably what you need; reason is that both DTR and RTS are off. Tested on Win10.

// Edit after below comment:
Adjust COM5 to your needs

How do you know that it's COM5? Detection of the real and right Arduino port requires some code.

Thanks, that was on my system; let's blame the lack of coffee in the morning :wink: Should have mentioned that it needs to be adjusted to OPs requirements.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.