Is it possible to input a keypress through serial monitor without hitting send ?
I'm using a wiimote control through glovpie to emulate keyboard presses. I was hoping to get "realtime" inputs without having to hit "send" after each entry.
I've seen used after some commands... I've messed around but can't get away from hitting send each time.
Any help would be great.
Thanks.
Here is the sketch...
////////////////////
const int dirpin = 2;
const int steppin = 12;
int incomingByte;
void setup()
{
Serial.begin(9600);
pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
incomingByte = Serial.read();
if(incomingByte == 'i')
ii();
if(incomingByte == 'j')
jj();
if(incomingByte == 'k')
kk();
if(incomingByte == 'm')
mm();
}
}
//////////////////////////////
void ii ()
{
int i;
digitalWrite(dirpin, LOW);//forward
delay(1);
for (i = 0; i<1600; i++)
{
digitalWrite(steppin, LOW);
digitalWrite(steppin, HIGH);
delayMicroseconds(200);
}
}
/////////////////////////////////
void mm ()
{
int i;
digitalWrite(dirpin, HIGH);//backward
delay(1);
for (i = 0; i<1600; i++)
{
digitalWrite(steppin, LOW);
digitalWrite(steppin, HIGH);
delayMicroseconds(200);
}
}
///////////////////////////////////
void jj ()
{
int i;
digitalWrite(dirpin, LOW);
delay(1);
for (i = 0; i<800; i++)
{
digitalWrite(steppin, LOW);
digitalWrite(steppin, HIGH);
delayMicroseconds(1800);
}
}
////////////////////////////////////
void kk ()
{
int i;
digitalWrite(dirpin, HIGH);
delay(1);
for (i = 0; i<800; i++)
{
digitalWrite(steppin, LOW);
digitalWrite(steppin, HIGH);
delayMicroseconds(1800);
}
}
/////////////////////////////////////
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.