@liemph said in PaHub: Arduino code for setting port HIGH or LOW:
Port B of your M5Stack.
Thank you so much for explaining. It worked, hooray!! :-)
Just to help other newbies reading this topic in the future, Port B of the M5Stack is the black port on the device and is only available when you get the base with the battery (Plus). On previous devices this was clearly marked, but it is not the case on this model.
Then, all you need to do is to use I/O pin 26 on your code. The syntax code provided on "Examples -> M5Stack -> Unit -> Relay" has worked perfectly without modification.
#include <M5Stack.h>
void setup() {
M5.begin();
M5.Power.begin();
M5.Lcd.clear(BLACK);
M5.Lcd.setTextFont(4);
M5.Lcd.setTextColor(YELLOW, BLACK);
M5.Lcd.setCursor(50, 0, 4);
M5.Lcd.println(("Relay Example"));
//disable the speak noise
dacWrite(25, 0);
pinMode(26, OUTPUT);
}
void loop(void) {
digitalWrite(26, HIGH);
delay(2500);
digitalWrite(26, LOW);
delay(2500);
}
Again, thank you.