Good day,
Sorry for my weak English. I bought the Breadboard Adapter for LEGO Mindstorms. I used the engagement: https://www.dexterindustries.com/howto/connecting-ev3-arduino/
But I do not get any answer. EV3 will not show anything. I made a loop in EV3 in order to write continuous data to the Arduino. The k
value is empty in receiveData()
. Communication is not possible.
I need to send the sensor data to EV3.
Please help. I am a beginner.
My code arduino:
#include <Wire.h>
#define SLAVE_ADDRESS 0x04
Int = 0, flag = 0;
Void setup ()
{
Serial.begin (9600); // start serial for output
Serial.println ("Arduino SLAVE, LEGO master"); // show OK
Wire.begin (SLAVE_ADDRESS);
Wire.onReceive (received);
Serial.println (val); // show OK
Serial.println (flag); // show OK
Wire.onRequest (sendData);
Serial.println ( "prepared"); // show OK
}
Void loop ()
{
if (flag == 1)
{
Serial.print (val);
flag = 0;
}
// else {Serial.print ("flag 0");} // show OK
}
Void receiveData ()
{
Int k = Wire.available ();
Serial.print ( "to");
Serial.println (a); // notshow FALSE
while (Wire.available ()> 0)
{
val = Wire.read ();
flag = 1;
}
}
// callback for sending data
Void sendData ()
{
Wire.write (0x45);
Wire.write (48);
}
My EV3: Brick HW V0.60; Brick FW: V1.09E
Thank you very much.
Johny