We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi
im working on a wifi arduino project, and i want to use processing to communicate with the arduino, but i dont quite understand the term buffer and byte yet, so i was wondering how do i send a buffer/byte to arduino?
Arduino code
int lights =14;
/////Motor Pins/////////
int enableM = 5;
int aM = 3;
int bM = 2;
//////Steering Pins/////
int enableS = 6;
int aS = 7;
int bS = 4;
//////Temperature Sensor Setup//////
//---------------------------------------------------------------------------
void setup()
{
Serial.begin(9600);
pinMode(lights, OUTPUT);
pinMode(enableM, OUTPUT);
pinMode(aM, OUTPUT);
pinMode(bM, OUTPUT);
pinMode(enableS, OUTPUT);
pinMode(aS,OUTPUT);
pinMode(bS,OUTPUT);
WiFi.init();
}
void loop()
{
//Serial.println(Temp.Fahrenheit());
WiFi.run();
digitalWrite(enableM,HIGH);
digitalWrite(enableS,HIGH);
//////////////////////Lights/////////////
if(buffer[4] == 'O'){
digitalWrite(lights, HIGH);
}
if(buffer[4] == 'X'){
digitalWrite(lights, LOW);
}
/////////////////////////////////////////
//////////////Motor Control//////////////
if(buffer[0] == 'F')
{
digitalWrite(aM,HIGH);
digitalWrite(bM,LOW);
}
if(buffer[1] == 'B')
{
digitalWrite(aM,LOW);
digitalWrite(bM,HIGH);
}
if((buffer[1] == 'X') && (buffer[0] == 'X'))
{
digitalWrite(aM,LOW);
digitalWrite(bM,LOW);
}
////////////////////////////////////////
////////////Steering///////////////////
if(buffer[2] == 'L')
{
digitalWrite(aS,LOW);
digitalWrite(bS,HIGH);
}
if(buffer[3] == 'R')
{
digitalWrite(aS,HIGH);
digitalWrite(bS,LOW);
}
if((buffer[3] == 'X') && (buffer[2] == 'X'))
{
digitalWrite(aS,LOW);
digitalWrite(bS,LOW);
}
Serial.print(" buffer 0:");
Serial.print(buffer[0]);
Serial.print(" buffer 1:");
Serial.print(buffer[1]);
Serial.print(" buffer 2:");
Serial.print(buffer[2]);
Serial.print(" buffer 3:");
Serial.print(buffer[3]);
Serial.print(" buffer 4:");
Serial.print(buffer[4]);
Serial.println(":");
//delay(1);
}
I know the arduino code works, cause its a "robot diy" i downloaded and tested, the program uses visual studio, but i want to use processing cause its more like arduino.
the arduino code keeps calling buffer[0] to [4] how do i send these to Arduino from processing with the right values?