2

I have searchewd a few posts here, but I cannot find one that is exactly what I am looking for. In simple terms I am trying to send a character to my Arduino via bluetooth Automatically.

I have tried both Putty and Plink, but neither work automatically. Here is the commands I have tried so far:

command.bat | putty -serial com3 -sercfg 9600

Command.bat:

@echo off
timeout /t 5
echo 2

and

plink -load Arduino echo 2

This connects to the bluetooth adapter on the Arduino, but opens an Interactive console. I can hit the number 2 on the keyboard it is sends it correctly. However I want that to be sent automatically. I have timeout in there because it takes a few seconds to connect to the bluetooth.

Is there a way to do this so I can just run a bat file and have it send the commands automatically?

Webtron
  • 443
  • 2
  • 6
  • 18

1 Answers1

0

If the interactive console opens up and is the most present item, you can use the following code upon the interactive console startup...

@if (@CodeSection == @Batch) @then
@echo off
set SendKeys=CScript //nologo //E:JScript "%~F0"

rem wait for interactive console to appear before pressing 2 to initialize
timeout /t 5    
%SendKeys% "{2}"

goto :EOF

@end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));

Call it a cheap fix if you will, the code will call a javascript to press 2 for you. Im not sure how to tie it with your absolute program but this will run it automatically as the computer will simulate the input for you.

Jouster500
  • 762
  • 12
  • 25