const int led1= 12;
const int led2= 14;
const int led3= 26;
const int p1 = 2;
const int p2 = 4;
const int p3 = 15;

const int freq = 5000;
const int ledChannel = 1;
const int resolution = 8;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(led1, OUTPUT);
  pinMode(p1, INPUT);

  // for ledc
  ledcSetup(ledChannel, freq, resolution);
  ledcAttachPin(led2, ledChannel);
}

void loop() {
  int v1 = analogRead(p1);
  analogWrite(led1, v1);

  // for ledc
  int vv2 = analogRead(p2);
  int v2 = map(vv2, 0, 4096, 0, 255);
  ledcWrite(ledChannel, v2);

  // for DAC
  int vv3 = analogRead(p3);
  int v3 = map(vv3, 0, 4096, 0, 255);
  dacWrite(led3, v3);



  Serial.print("v1 : ");
  Serial.print(v1);
  Serial.print("  v2 : ");
  Serial.print(v2);
  Serial.print("  v3 : ");
  Serial.println(v3);
}