Hello people, i have a problem with my code, all it`s working ok, with one exception:
on the last section, last lines:
Serial.print("sometext");
if (digitalRead(go) == LOW){
display.clearDisplay();
display.display();
delay(200);
It`s print on serial, but when i push button (go), nothing happend. This is my all code:
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
int menu = 17;
int ok = 12;
int sel = 16;
int go = 21;
int q = 0;
int vok = 0;
int menulock = 0;
String inputString;
int i = 0;
int v = 0;
int j = 0;
void setup() {
Serial.begin(9600);
pinMode(menu, INPUT_PULLUP);
pinMode(ok, INPUT_PULLUP);
pinMode(sel, INPUT_PULLUP);
pinMode(go, INPUT_PULLUP);
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
display.setTextSize(2);
display.setTextColor(WHITE);
display.clearDisplay();
display.display();
display.setCursor(10, 12);
display.print("PASSWORD");
display.display();
}
void loop(){
if (menulock == 0 && digitalRead(menu) == LOW){
i++;
if (i > 9){
i = 0;
}
display.clearDisplay();
display.setCursor(10, 12);
display.print(i);
display.display();
delay(200);
}
if (vok < 4 && digitalRead(ok) == LOW){
vok++;
inputString += i; // append new character to input string
delay(400);
display.setCursor(0, 10);
display.clearDisplay();
display.print(inputString);
display.display();
if (vok > 3){
vok=4;
menulock = 1;
}
}
if (q == 0 && vok == 4 && menulock == 1 && digitalRead(sel) == LOW){
q++;
if (inputString != "1234"){
display.setTextSize(2);
display.setCursor(25, 0);
display.clearDisplay();
display.print("invalid");
display.display();
delay(200);
} else {
Serial.print("sometext");
if (digitalRead(go) == LOW){
display.clearDisplay();
display.display();
delay(200);
}
}
}
}
I use a raspberry pi pico.
Thank you very much for you`re help!