so ive created this code :
#include <Servo.h>
Servo testServo;
int pos = 0;
char w = "w";
char s = "s";
void setup() {
Serial.begin(9600);
testServo.attach(9);
}
void loop() {
char rx_byte;
if (Serial.available() > 0) { // is a character available?
rx_byte = Serial.read(); // get the character
Serial.print("You typed: ");
Serial.println(rx_byte);
if(rx_byte == w)
{
pos=pos+1;
}
if(rx_byte == s)
{
pos=pos-1;
}
Serial.println(pos);
}
}
which suppose to up the pos variable by one if w is pressed, or lower it by 1 if s is pressed, im using arduino nano
originally i meant the pos to be up when pressing arrow up key and pos down by arrow down key, but couldnt check arrows (i think its better to see it in ASCI II but i forgot how xD so for now ill use w and s)
but those warnings shows up (and the code doesnt work)
G:\Arduino tests\sketch_jun23a\sketch_jun23a.ino:6:10: warning: invalid conversion from 'const char*' to 'char' [-fpermissive]
char s = "s";
anyone have any suggestion how can i check (in an if) what letter was pressed?