commande-serie.ino
The Minima has no radio: the USB serial port becomes its control interface. This mini server toggles the LED and trims the 12-bit DAC per keystroke — perfect to test a circuit from a PC script.
Hardware
An Arduino UNO R4 Minima (Renesas RA4M1, Cortex-M4 @ 14 MHz, 5 V, 12-bit DAC, no radio) powered by USB or 6-24 V. None to test; DAC A0 to a multimeter for the demo.
Wiring
LED on 13 (or LED_BUILTIN); A0 to the measuring instrument. Serial monitor at 9600 baud, line ending "none".
How it works
Serial.available/read reads characters without blocking; the switch runs the command and replies. analogWriteDAC0 applies the voltage on A0.
Running it
Arduino IDE 2.x (with the « Arduino UNO R4 Boards » core installed), pick « Arduino UNO R4 Minima », select the port and Upload. The serial monitor runs at 9600.
Variants
Replace letters with "dac=1234" lines (readStringUntil), or drive from Python (pyserial) for an automated test bench.
commande-serie.ino
// Mini-serveur serie : 'l' LED, 'u'/'d' DAC, 's' etat.
const int LED = 13;
int dac = 2048; // consigne DAC 0..4095
bool ledOn = false;
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(9600);
Serial.println(F("l=LED u/d=DAC s=etat"));
}
void loop() {
if (!Serial.available()) return;
char c = Serial.read();
switch (c) {
case 'l':
ledOn = !ledOn;
digitalWrite(LED, ledOn);
Serial.println(ledOn ? F("LED ON") : F("LED OFF"));
break;
case 'u':
dac = min(4095, dac + 128);
analogWriteDAC0(dac);
Serial.println(dac);
break;
case 'd':
dac = max(0, dac - 128);
analogWriteDAC0(dac);
Serial.println(dac);
break;
case 's':
Serial.print(F("LED=")); Serial.print(ledOn);
Serial.print(F(" DAC=")); Serial.println(dac);
break;
}
}