Hello everyone, I am new.
I recently bought a 3pi and I have the following problem:
I am using the code example serial1 in where I have added from another example a method that gives the voltage of the battery. The method follows:
void bat_test()
{
int bat = read_battery_millivolts();
print_long(bat); // This works prints on the screen
print("mV"); // This line also works, it prints
memcpy_P(send_buffer, bat, 10); // my problem is here
serial_send(send_buffer, 10); // and here
delay_ms(300);
}
In the serial1 example I have added the above method and I have also added a new case to the switch statement:
case 'b':
bat_test();
break;
Therefore, when I send from the laptop a b it calls the bat_test(). The communication works, when I send a b it prints on the 3pi LCD screen but it doesnot send me back a correct buffer on my laptops console.
If you ask me why I have placed the number 10 on the buffer I do not know I was trying randomly. I think that number represents the bytes of the buffer? Without being sure.
I want to know how can I send variables from the program space to the serial port?
I know it is something easy for most of you in here, but I cannot find it.
Thank you in advance, for all your replies!