Help Combining two programs

Hi, I was wondering if anyone would be able to help. I am trying to combine two programs together. One program with a motor and one for an array of LDR’s. Im finding that its not quite working. Im still a beginner and finding some elements quite difficult. Ive watch a few youtube tutorials and tried to apply the same technique but I’m finding that when compiled there are no errors but the motor won’t move like its meant to and I try again but slightly different and there are no numbers showing in the serial monitor. I would really appreciate some pointers or some help putting it together. thank you in advance =]

LDR.ino (930 Bytes)

FL0BZA6HNTTEFKD.ino (10.5 KB)

I am trying to combine two programs together.

So, you should have three programs - the two that do something separately and your attempt to produce a single program that does both things. You forgot to post one of your programs.

Before you can combine two programs, you need a set of requirements for the resulting program. You have not posted those requirements.

Your attempt to combine the codes does something that you didn't describe. You expect it to do something that you didn't describe.

No one can help you get your program working based only on what you have posted so far.

I would suggest that you start with a simple program to control a single motor.
Apply simple controls over the motor movement and direction. There are a lot of samples available online.

With just reading some of the reference manuals available, you will see a lot of helpful tips on many common problems that your experiencing..

sorry for not posting my attempt at the program. I have attached my program so far trying to merge the two original that I posted. The motor is behaving exactly how I want it. The only issue I have now is that the serial monitor is posting continuous question marks instead of the LDR output from pins A0-A5. Thank you

Motor_LDR_Blend.ino (11.8 KB)

int LDRReading0 = analogRead(LDR_Pin0);
int LDRReading1 = analogRead(LDR_Pin1);
int LDRReading2 = analogRead(LDR_Pin2);
int LDRReading3 = analogRead(LDR_Pin3);
int LDRReading4 = analogRead(LDR_Pin4);
int LDRReading5 = analogRead(LDR_Pin5);

It is pointless to call analogRead() outside of a function. You do not know whether the hardware is ready, here, or not.

int a, b, c, d, e, f, g, h, i = 0;       // Iniating the note status markers.

Terrible names for global variables.

  if ( (analogRead(0) > sensor ) && (a == 0) ) // If the sensor gets a signal, and the not is not playing:

sensor is a terrible name for a threshold value.

  Serial.print("Light A0: ");Serial.print(LDRReading0);
  Serial.print("     Light A1: ");Serial.println(LDRReading1);
  Serial.print("Light A2: ");Serial.print(LDRReading2);
  Serial.print("     Light A3: ");Serial.println(LDRReading3);
  Serial.print("Light A4: ");Serial.print(LDRReading4);
  Serial.print("     Light A5: ");Serial.println(LDRReading5);

You haven't actually read the relevant pins, so you are printing garbage.

jervo92:
sorry for not posting my attempt at the program. I have attached my program so far trying to merge the two original that I posted. The motor is behaving exactly how I want it. The only issue I have now is that the serial monitor is posting continuous question marks instead of the LDR output from pins A0-A5. Thank you

Sounds like a baudrate mismatch to me. Is Serial Monitor set to 9600?