Hello everybody and thanks in advance for your help.
I am testing the basics feature of the AB02S… And I having a veru strange issue… I am using one switch in the GPIO07, and one led in the GPIO10. I am also using hte OLED to show the Switch Status… When I do not operate the LED, the OLED works just fine. But as soon as I include the swithc veryfication rutine to set the Led on and off the OLED does black and never returns… It is really strange, as soon as a digitalWrite function is used, the OLED goes black…
Any idea of what could be happening?
Thank you all in advance
This is the wiring
And this is the code:
#include <Wire.h>
#include “HT_SSD1306Wire.h”
SSD1306Wire display(0x3c, 500000, SDA, SCL, GEOMETRY_128_64, GPIO10); // addr , freq , SDA, SCL, resolution , rst
// constants won’t change. They’re used here to set pin numbers:
const int buttonPin = GPIO7; // the number of the pushbutton pin
const int ledPin = GPIO10; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int counter = 1;
void VextON(void)
{
pinMode(Vext,OUTPUT);
digitalWrite(Vext, LOW);
}
void VextOFF(void) //Vext default OFF
{
pinMode(Vext,OUTPUT);
digitalWrite(Vext, HIGH);
}
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
// initialize display
Serial.begin(115200);
VextON();
delay(100);
display.init();
display.clear();
display.display();
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.setFont(ArialMT_Plain_16);
display.drawString(64, 32-16/2, “Iniciando…”);
display.display();
delay(2000);
}
void loop() {
// put your main code here, to run repeatedly:
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// Info to be displayed
char str[30];
display.clear();
display.setFont(ArialMT_Plain_16);
sprintf(str,“Contador = (%d)”, counter);
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(0, 0, str);
sprintf(str,“Interruptor = (%d)”, buttonState);
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(0, 15, str);
// write the buffer to the display
display.display();
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
//digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
//digitalWrite(ledPin, LOW);
}
delay(500);
counter++;
}