Bluno General Arduino

2 Bluno Beetles--communication issues with simple code and serial

userHead Account cancelled 2020-07-02 05:09:05 2551 Views1 Replies
Can someone help me. I am trying to send mapped analog values from 0 to 100 from a master bluno beetle to a linked/paired slave bluno beetle. I want the slave to take the value and multiply it by a value and print the result to the serial monitor. It doesn't seem to work though.

I feel like its an issue with the bluno beetles using the serial communication and me trying to use the serial monitor at the same time but maybe not. Right now I get the value from the master beetle and it shows up on slave serial monitor but it never prints the values value to the screen or anything else.

Thank you,
Code: Select all
//Master Code


int old_value;  //Prior reading value from analogRead

void setup()
{
  Serial.begin(115200);
  Serial.print("Simple Master Beetle Program--BLUETOOTH");
}

void loop()
{

  //Current code that takes and maps analog value from potentiometer and sends to slave device.
  int mappedValue = map(analogRead(A0), 0, 1023, 0, 100);
  if (abs(mappedValue - old_value) > 1) {
    old_value = mappedValue;  // save the changed value
    Serial.println(mappedValue);
    //Serial.write("");
    //Serial.write(mappedValue);
  }
delay(1000);
}

Code: Select all
//Slave Code

int values = 10;
char com;

void setup()
{
  Serial.begin(115200);
  Serial.println("Simple Slave Beetle Program----BLUETOOTH");
}

void loop()
{

  while (Serial.available() > 0) {
    com = Serial.read();
    Serial.println("Yes");
    delay(10);
    Serial.println(com);
    values = values * com;
    Serial.print("Values is: ");
    Serial.println(values);
  }

}