Hello Friends;
Is it possible with Node -Red. Can ı use serial communication for that, for example;
When I blink, ı want to send to my arduino data "w" and w is setted as forward in arduino. laugh data "s" to backward
Or there is difference method to do this.
This project is important for my internship my friends, if you can help me about it. You will make me happy.
Thanks
my codes
// Mind Controlled Robot with Emotiv Insight
int r_mtr_n = 2; // assign motor pins to arduino
int r_mtr_p = 4;
int l_mtr_p = 5;
int l_mtr_n = 7;
int incomingByte = 0; // assign pin for bluetooth module
void setup()
{
pinMode(r_mtr_n, OUTPUT);
pinMode(r_mtr_p, OUTPUT);
pinMode(l_mtr_p, OUTPUT);
pinMode(l_mtr_n, OUTPUT);
digitalWrite(r_mtr_n, LOW);
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.begin(9600);
Serial.println("start");
}
void loop()
{
if (Serial.available() > 0) {
incomingByte = Serial.read();
}
switch(incomingByte)
{
case 'w':
digitalWrite(r_mtr_n, HIGH); // control for forward
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, HIGH);
Serial.println("forward\n");
incomingByte='*';
break;
case 's':
digitalWrite(r_mtr_n, LOW); // control for backward
digitalWrite(r_mtr_p, HIGH);
digitalWrite(l_mtr_p, HIGH);
digitalWrite(l_mtr_n, LOW);
Serial.println("backwards\n");
incomingByte='*';
break;
case 'f':
digitalWrite(r_mtr_n, LOW); // control for stop
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, LOW);
Serial.println("Stop\n");
incomingByte='*';
break;
case 'd':
digitalWrite(r_mtr_n, HIGH); // control for right
digitalWrite(r_mtr_p, LOW);
digitalWrite(l_mtr_p, HIGH);
digitalWrite(l_mtr_n, LOW);
Serial.println("right\n");
incomingByte='*';
break;
case 'a':
digitalWrite(r_mtr_n, LOW); // control for left
digitalWrite(r_mtr_p, HIGH);
digitalWrite(l_mtr_p, LOW);
digitalWrite(l_mtr_n, HIGH);
Serial.println("left\n");
incomingByte='*';
break;
delay(5000);
}
}