Hi all!
I am trying to do an I2C from Mega to UNO and I am trying to look for a solution on this very simple problem however I am unable to find anything related to my query, so please bear with me.
Anyway, I am receiving this error code 'requestEvent' was not declared in this scope
Here's my slave's code:
#include <Wire.h>
int DO = 2; //Pin for Digital Output - DO
int DA = A0; // Pin for Analog Output - AO
int threshold = 532; //Set minimum threshold for LED lit
int sensorvalue = 0;
int North[] = {2, 3, 4};
int West[] = {5, 6, 7};
int South[] = {8, 9, 10};
int East[] = {11, 12, 13};
int redDelay = 5000;
int yellowDelay = 2000;
void setup() {
 for (int i = 0; i < 3; i++) {
  pinMode(North[i], OUTPUT);
  pinMode(West[i], OUTPUT);
  pinMode(South[i], OUTPUT);
  pinMode(East[i], OUTPUT);
  Serial.begin(9600);
 Wire.begin(8);
 Wire.onRequest(requestEvent);
}
void loop() {
 sensorvalue = analogRead(DA); //Read the analog value
 //Serial.print("Analog: ");
// Serial.print(sensorvalue);Â //Print the analog value
// Serial.print("Â ");
// Serial.print("Digital: ");
// Serial.println(digitalRead(DO));Â //Print the digital value
Â
}
 void requestEvent() {
 Â
  if (sensorvalue >= threshold) { //Compare analog value with threshold
  digitalWrite(North[1], HIGH);
  digitalWrite(West[1], HIGH);
  digitalWrite(South[1], HIGH);
  digitalWrite(East[1], HIGH);
  delay(yellowDelay);
  digitalWrite(North[0], HIGH);
  digitalWrite(West[0], HIGH);
  digitalWrite(South[0], HIGH);
  digitalWrite(East[0], HIGH);
  digitalWrite(North[1], LOW);
  digitalWrite(West[1], LOW);
  digitalWrite(South[1], LOW);
  digitalWrite(East[1], LOW);
  delay(redDelay);
  }
 Â
 }
I am pretty sure of my code and that I have declared it (as seen above). Just want to see what could be my possible error on this.
Thank you all! <3