Manuale Mercury V1
Scopri come volare velocemente con facilità, collega il tuo altimetro per caricare il sito web Altimeter Cloud e accedi a tutte le funzionalità avanzate. Se sei bloccato o stai appena iniziando, questo è il posto giusto.

Esempio di codice: Rilevamento dell'alimentazione USB

PDF

L'altimetro Mercury ha un partitore di tensione collegato al pin definito come USBDETECT.
Se l'USB è presente (5V) allora il pin USBDETECT leggerà 1 (HIGH), quando nessun USB è collegato leggerà 0 (LOW)

Usi Arduino IDE? Il nostro programmatore online include Mercury_Pins.h per impostazione predefinita, quindi i nomi dei pin funzionano senza problemi. Se utilizzi Arduino IDE o un altro programmatore, copia il contenuto della scheda Mercury_Pins.h e incollalo nella parte superiore del tuo programma.
/*
 * Mercury V1 (ESP32-C6) Detecting USB
 * You can detect the presense of a USB by reading the state of USBDETECT
 */
#include "Mercury_Pins.h"

void setup() {
    pinMode(USBDETECT, INPUT);     // You need to set the USBDETECT as a input
    Serial.begin(115200);
    delay(1000);
}
void loop() {
    if(digitalRead(USBDETECT) == 1){
        // USB detected
    }
    if(digitalRead(USBDETECT) == 0){
        // No USB connected
    }
    delay(500);
}

#pragma once
/*
 * Mercury (ESP32-C6) Pin Definitions
 * Board-specific GPIO assignments
 */

// ── Status LED (NeoPixel) ──
#define LEDPOWER      3    // NeoPixel power (drive HIGH to enable)
#define LED           2    // NeoPixel data signal

// ── I2C Bus ──
#define SDA           21   // I2C data
#define SCL           22   // I2C clock

// ── Sensor Power ──
#define VACC          20   // Sensor power rail (drive HIGH to enable)

// ── General Purpose Ports ──
#define GP06          6    // GP06 port
#define GP07          7    // GP07 port

// ── High Current Output ──
#define OUT1          5    // High current output (e.g. pyro / relay)

// ── Battery Bar LEDs ──
#define BL1           4    // Battery LED 1 (lowest)
#define BL2           14   // Battery LED 2
#define BL3           15   // Battery LED 3
#define BL4           18   // Battery LED 4
#define BL5           19   // Battery LED 5 (highest)

// ── Indicators ──
#define DISK          8    // Disk activity LED

// ── Analogue / Detection ──
#define BATIN         0    // Battery voltage (1:1 divider)
#define USBDETECT     1    // USB power detect (HIGH = USB present)
#define BUTTON        9    // BUTTON on the board, boot button but can be used