int16_t data_sensor = 0; //ini adalah variabel global denga tipe data integer 16bit
int16_t data_sensor_jarak[10];

struct Sensor {
  int64_t data_potensio[2];
  int16_t data_gyro[6];
  bool data_pir;
}; Sensor sens;

#define pin_pir 19
const int8_t pin_pot1 = 33;
const int8_t pin_pot2 = 35;

void setup() {
  // put your setup code here, to run once:

  pinMode(pin_pir, INPUT_PULLUP);

  Serial.begin(115200);
  Serial.println("Hello, ESP32!"); 
}

void loop() {
  // put your main code here, to run repeatedly:
  data_sensor_jarak[0] = baca_sensor(35);
  data_sensor_jarak[1] = baca_sensor(33);

  sens.data_potensio[0] = baca_sensor(pin_pot1);
  sens.data_potensio[1] = baca_sensor(pin_pot2); 
  sens.data_pir = digitalRead(pin_pir);

  Serial.print("Contoh Array => "); 
  Serial.print("Pot1 :");
  Serial.print(data_sensor_jarak[0]);
  Serial.print(" Pot2 :");
  Serial.print(data_sensor_jarak[1]);
  
  Serial.print(" Contoh Struct => "); 
  
  Serial.print("Pot1 :"); 
  Serial.print(sens.data_potensio[0]);
  Serial.print(" Pot2 :"); 
  Serial.print(sens.data_potensio[1]);
  Serial.print(" PIR :");
  Serial.print(sens.data_pir);

  Serial.println();

  delay(10); // this speeds up the simulation
}

int16_t baca_sensor(int8_t pin_sensor){
  int16_t data_sensor;  //ini adalah variabel global denga tipe data integer 16bit

  data_sensor = analogRead(pin_sensor);

  return data_sensor;
}