7seg2403 — ESP32 simulation

An interactive ESP32 circuit simulation you can run free in your browser on Velxio, by lingl_205.

Components

Sketch code

const byte sPin[]={22,32,33,25,26,27,14,12};
const int kPin=23;
int kNum=0;
byte sCode[11][8]={
  {1,1,1,1,1,1,0,0},//0
  {0,1,1,0,0,0,0,0},//1
  {1,1,0,1,1,0,1,0},//2
  {1,1,1,1,0,0,1,0},//3
  {0,1,1,0,0,1,1,0},//4
  {1,0,1,1,0,1,1,0},//5
  {1,0,1,1,1,1,1,0},//6
  {1,1,1,0,0,0,0,0},//7
  {1,1,1,1,1,1,1,0},//8
  {1,1,1,1,0,1,1,0},//9
  {0,0,0,0,0,0,0,0}//不显示
};
void disp(int n){
  for(int i=0;i<8;i++){
    digitalWrite(sPin[i],sCode[n][i]);
  }
}
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Hello, ESP32!");
  pinMode(kPin, INPUT);
  for(int i=0;i<8;i++){
    pinMode(sPin[i], OUTPUT);
  }
  disp(10);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (!digitalRead(kPin)) {
    kNum++;
  }
  disp(kNum);
  Serial.println(kNum);
  delay(800); // this speeds up the simulation
}

More projects by lingl_205