I was trying to print some values coming into the Arduino UNO I was testing but the values were not printing to the IDE monitor. Commenting out much of the Setup commands allowed the print-to-monitor to work. If I uncomment one command, nothing prints. I/m using IDE 2.3.2.
In the attached code, I have one print statement in the Loop function, all else in the loop is commented out. In Setup, I have only two commands uncommented and the print function works. If I uncomment the next line (lcd.begin()), I don't get the print. Uncommenting the other commands, between the lcd commands, don't have an effect (printing works), but if I uncomment even ONE LCD command at the end of the Setup function, printing does not work.
In other words, any lcd command stops the printing. What's going on? I've used these lcd commands and function many, many times before.
const int stepPin1 = 4; // All constants and pins below are for the Blueboy shield
const int dirPin1 = 5; //low is one direction, high is other direction
const int stepPin2 = 2;
const int dirPin2 = 3;
const int Start1 = 9; //jog or continuous start
const int Start2 = 8;
#define pot1 A0
#define pot2 A1
#define STEPS 200
const int STEPS_PER_REV = 200;
#define motorInterfaceType 1
const int LED1 = 11;
const int LED2 = 10;
//int pot1 = 0;
//nt pot2 = 0;
int readPot1 = 0;
int readPot2 = 0;
int speedlcd1, speedlcd2, speedDelay1, speedDelay2;
//#define Mode1
//#define Mode2 //Jog or Continuous selection
#include <Wire.h>
#include <Stepper.h>
#include <LiquidCrystal_I2C.h> // Using version 1.2.1
LiquidCrystal_I2C lcd(0x27, 16, 4);
Stepper M1(STEPS, dirPin1, stepPin1);
Stepper M2(STEPS, dirPin2, stepPin2);
/*************************SETUP*****************************/
void setup() {
Serial.begin(19200);
Wire.begin(); // start I2C
//lcd.begin(16,4);
//lcd.backlight();
M1.setSpeed(1000); //set maximum speed
M2.setSpeed(1000);
pinMode(stepPin1, OUTPUT); //
pinMode(dirPin1, OUTPUT);
pinMode(stepPin2, OUTPUT); //
pinMode(dirPin2, OUTPUT);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(Start1, INPUT_PULLUP); //Switch common is to ground
pinMode(Start2, INPUT_PULLUP); //same-o
//lcd.setCursor(0,0);
//lcd.print("FE");
//lcd.setCursor(0,1);
// lcd.print("IndianHarbour");
// delay(4000);
// lcd.clear();
} //end Setup function
void loop() {
Serial.println("In the Loop function");
//SpeedM1();
//SpeedM2();}
//backforth(); //tested both motors and both A4988 okay works
/* PB and LED test. Press button, light LED. Switch common to ground. okay works
if (digitalRead(Start1)==LOW){
digitalWrite(LED1, HIGH);
delay(250);
digitalWrite(LED1, LOW);
delay(250);}\
*/
} //end Loop function
/***********************M1 and M2 Forware/Reverse******************************************/
void backforth() { // This is for M1
digitalWrite(dirPin1, HIGH); //
Serial.println("forward");
for (int x = 0; x < 1600; x++) {
digitalWrite(stepPin1, HIGH);
delayMicroseconds(500);
digitalWrite(stepPin1, LOW);
delayMicroseconds(500);
} //end for loop
delay(1000);
digitalWrite(dirPin1, LOW);
Serial.println("Reverse");
for (int x = 0; x < 1600; x++) {
digitalWrite(stepPin1, HIGH);
delayMicroseconds(500);
digitalWrite(stepPin1, LOW);
delayMicroseconds(500);
} //end for loop
Serial.println("end of second loop, 400 steps");
delay(1000);
} //end backforth function
/***********************M1 and M2 Speed******************************************/
void SpeedM1() {
Serial.println("in SpeedM1 function");
readPot1 = analogRead(pot1);
speedDelay1 = map(analogRead(readPot1), 0, 0, 1023, 1000);
Serial.print(speedDelay1);
Serial.println(readPot1);
speedlcd1 = map(analogRead(readPot1), 0, 0, 1023, 1000);
//lcd.setCursor(0,0);
//lcd.print("Speed M1 = ");
// lcd.print(speedDelay1);
digitalWrite(stepPin1, HIGH);
delayMicroseconds(speedDelay1);
digitalWrite(stepPin1, LOW);
delayMicroseconds(speedDelay1);
}
void SpeedM2() {
Serial.println("in SpeedM2 function");
readPot2 = analogRead(pot2);
speedDelay2 = map(analogRead(readPot2), 0, 0, 1023, 1000);
speedlcd2 == map(analogRead(readPot2), 0, 1023, 0, 100);
// lcd.setCursor(0,1);
// lcd.print ("Speed M2 = ");
//lcd.print(speedDelay2);
digitalWrite(stepPin2, HIGH);
delayMicroseconds(speedDelay2);
digitalWrite(stepPin2, LOW);
delayMicroseconds(speedDelay2);
}