(sorry for bad English, I'm German)
Hello programmers,
I'm trying (without success) to send data from an Raspberry Pi 3(master) to an Arduino(slave):
Here's my updated Arduino Code:
#include <Wire.h>
volatile bool flag = false;
void wireHandler(int numBytes)
{
flag = true;
}
void setup()
{
pinMode(13, OUTPUT);
Wire.begin(0x23);
Wire.onReceive(wireHandler);
}
void loop()
{
delay(100);
digitalWrite(13, flag);
}
My Raspy code (C++, g++ main.cpp -lwiringPi):
#include <iostream>
#include <wiringPi.h>
#include <wiringPiI2C.h>
int main(void)
{
if(wiringPiSetup() == -1)
{
std::cerr << "wiringPiSetup() == -1\n";
return 1;
}
if(wiringPiI2CSetup(0x39) == -1) //is 0x39 correct?
{
std::cerr << "wiringPiI2CSetup(int) == -1\n";
return 1;
}
while(true)
{
wiringPiI2CWrite(0x23, 0x23);
delay(100);
}
}
In theory this should make the Arduino Led (pin 13) blink. However the led stays dark.
I would be thankful if anyone could explain me why this program does not work and how to fix it.
And yes I2C is activated in Raspi-Config.