Project Guidance needed!

Hi, I'm working on a bigger Project with 2 Arduino Mega 2560. Also i'm using lots of relays, an 4x4 Keypad and an 20x4 lcd via i2c. By the end this control hast be built in a Pinball. the Pinball is erased and there is just the Frame. it's a Gimmick for MeTec2015 for my daddy's Company. there are 5 parts of steel which have to be descaled. The big theme about it is "Selective Descaling". so there are 5 targets at the top of the play field. at the lower side of the play field you can find 5 buttons. if you press a Butte water will be shot throughh the Playfield and hit the Target. Water hydraulics are made by my fathers Company. Also there are lots of LED's which light in sections. Thats about the Hardware.

so now about the Arduino Part: the first Arduino controls the Game itself he lights up 1 of the 5 less randomly. After that you have to "descale" the target by pressing the right button. You have a delay(reaction time) and if you don't get it to the right time you fail. If you get it you Proceed to Level 2 noe there are 2 Targets lighted up at the same time wich have to be descaled... Last Level there are 4 out of 5 Targets.

Timing and different Gamemodes have to be toggled about an LCD Interface with the Keypad. this is coordinated by 2nd arduino. also he puts out LED Signals over Realis and pwm Amplifier.

Now to what i already got: -random algorithm for the Signals. (Running) -writing agorithm for Signals. (Running) -input check Algorithm (NOT tested) -LCD Menue Structure(Running) -LCD Menue Function to change the Numbers (WORKING) -I2C Communication and Protocoll for communication between 2nd (master) and 1st ( Slave) (NOT WORKING)

Any help would be great. For the Function to change numbers i got an idea. ill write about it in the next Post. Help via teamspeak, Skype or FaceTime is really appreciated

greetings, Max

nicotin1602:
Any help would be great.

If you really want help, post your code ! (and hopefully it is nicely documented and easy to understand.

And please read “How to use the Forum” - help us to help you.

…R

So Today i finished a n Example Code for changin numbers and sending them over I2C. if the receiver Code works i should be fine! but here my Example:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

char reaktionszeit[6] = "12345";
char key;
int i = 0;
int x = 0;
int y = 0;
int xi = 0;


//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

const byte ROWS = 4;
const byte COLS = 4;
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3','U'},
  {'4','5','6','D'},
  {'7','8','9','E'},
  {'L','0','R','B'}
};
// Connect keypad      R0 R1 R2 R3
byte colPins[COLS] = { 22, 24, 26, 28 };
// Connect keypad      C0, C1  C2  C3
byte rowPins[ROWS] = { 30, 32, 34, 36 }; 

// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int fortransmitt(char t[2] = "X",char v[6] = "XXXXX"){
  char totransmitt[7] = "XXXXXX";
  totransmitt[0] = t[0];
  totransmitt[1] = v[0];
  totransmitt[2] = v[1];
  totransmitt[3] = v[2];
  totransmitt[4] = v[3];
  totransmitt[5] = v[4];

  Wire.beginTransmission(1);
  Wire.write(totransmitt);
  Wire.endTransmission();
  Serial.println(totransmitt);
}

void setup()  
{
  Serial.begin(9600); 
  lcd.begin(20,4); 
  lcd.backlight(); 
  lcd.clear();
  x = 3;
  y = 2;
  lcd.setCursor(x,y);
  lcd.write(reaktionszeit);
  
}

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  key = kpd.getKey();
  if (key == 'L' || key == 'R')
   {
   switch (key)
   {
    case 'L':
    if (i > 0){i = i - 1;}
    break;
    
    case 'R':
    if (i < 4){i = i + 1;}
    
    break;
   }
      
   }
  xi = x + i;
  lcd.setCursor(xi,y);
  lcd.blink();
  lcd.cursor();
  if (key >= '0' && key <= '9' ){
  reaktionszeit[i] = key;
  lcd.setCursor(x,y);
  lcd.write(reaktionszeit);
  lcd.setCursor(xi,y);
  }
  
  if (key == 'E')
  {
    char vartype[2] = "r";
    fortransmitt(vartype,reaktionszeit);
  }
}

nicotin1602:
if the receiver Code works i should be fine!

Let us know how your testing works out.

…R

So, you didn't read all of the "How to use this forum".