Hello! Am currently experiencing an issue where I upload my code onto an STM32F401RE board and while it works perfectly fine plugged in to my laptop with the code, when I try to plug into another outlet and test the code the LCD display won't display the text I have written.
#include <Servo.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(6, 7, 8, 9, 10, 11);
Servo servo1;
int servoposition = 0;
const int BUTTON_PIN = 2;
const int LED_PIN = 3;
byte lastButtonState = LOW;
byte ledState = LOW;
const unsigned long eventInterval = 55;
unsigned long previousTime = 0;
void setup(){
servo1.attach(5);
pinMode(BUTTON_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
lcd.begin(16, 2);
Serial.begin(9600);
}
void loop() {
// TEST CASE 1
// PUSHBUTTON
byte buttonState = digitalRead(BUTTON_PIN);
if (buttonState != lastButtonState) {
lastButtonState = buttonState;
if (buttonState == LOW) {
ledState = (ledState == HIGH) ? LOW: HIGH;
digitalWrite(LED_PIN, ledState);
}
}
// TEST CASE 2
// SERVO
// for(int position = 0; position <= 180; position += 1){
// servo1.write(position+5);
// }
// for(int position = 180; position >= 0; position -= 1){
// servo1.write(position-5);
// }
// }
// TEST CASE 3
//LCD
lcd.setCursor(0, 0);
lcd.print("Hello World!");
}
I am still currently adding more code onto this (which explains several unused variables)
When I plug into another device, test case 1 works perfectly fine but the text from test case 3 will not appear. Am unsure why if there was an uploading error how one part of the code would work while the other does not instead of just everything not working. Any help would be appreciated!