🛠 Potentiomètre et sortie DAC sur la prise audio du GIGA R1

Arduino GIGA R1 · debutant · Schéma : IMG-giga-r1-d3-1-potentiometre-dac-audio.svg — Potentiomètre alimenté en 3,3 V relié à l'entrée A0 du GIGA R1, et prise jack 3,5 mm de la carte reliée à un haut-parleur via la sortie DAC0.

Objectives

Discover the analog world of the GIGA R1: read a voltage using an analog-to-digital converter (3 ADCs on the STM32H747XI) and generate a signal with a digital-to-analog converter (2 DACs, 12 bits). A specific feature of this board: the 3.5 mm audio jack is wired to DAC0, DAC1, and A7 — a real sound project without a shield.

Hardware

Complete code

// GIGA R1 WiFi — son d'onde en dent de scie sur DAC0 (prise jack), hauteur = A0
#include <Arduino.h>

const int KNOB_PIN = A0;   // potentiomètre 0..3,3 V
const int DAC_PIN  = DAC0; // sortie DAC reliée à la prise jack embarquée
uint32_t phase = 0;

void setup {
  Serial.begin(115200);
  analogWriteResolution(12);   // le DAC du STM32H747XI est 12 bits (0..4095)
  Serial.println("Tournez le potentiometre");
}

void loop {
  uint32_t pas = 1 + map(analogRead(KNOB_PIN), 0, 4095, 0, 63);
  phase = (phase + pas) & 0xFFF;   // retour à zéro sur 12 bits
  analogWrite(DAC_PIN, phase);      // dent de scie -> son modulable
}

Potentiometer wiring: wiper to A0, one end to 3.3 V, the other to GND.

Expected verification

Turning the potentiometer progressively increases the pitch of the sound generated in the headphones. By displaying analogRead(A0) on the Serial Monitor, the value follows the wiper from 0 to approximately 4095.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials