bonjour tout le monde,
j’ai un soucis d’interferences avec mon montage a base d’arduino nano (oldbootloader) et de tft GMT020-02-7P….
quand je branche les entrées de signaux audio et que le nano se trouve à proximité du Bluetooth de l’ampli sa flash le code que j’ai uploadé au bout de quelques seconde et l’ecran se fige, idem quand le câble du générateur de fréquences et a proximitée immédiate.
y a t’il un filtrage (composants) ou un blindage type (cage de faraday a mettre en place) pour regler se problème, ou , carrement changer d’arduino pour passer sur esp32 (que je ne possède malheureusement pas)
le code ci dessousa été bricolé avec l’IA Copilot vu que je suis nul en codage !!!
un grand merci à tous pour les réponces que vous pouriez m’apporter
#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include <SPI.h>
#define TFT_CS 10
#define TFT_DC 8
#define TFT_RST 9
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
// MSGEQ7 pins
#define STROBE 4
#define RESET 5
#define LEFT_IN A0
#define RIGHT_IN A1
// Colonnes dynamiques
const int colWidth = 3;
const int colSpace = 2;
const int numCols = 64; // calculé pour 320 px
const int baseX = 7; // centré automatiquement
int leftBands[numCols];
int rightBands[numCols];
int peakL[numCols] = {0};
int peakR[numCols] = {0};
// Layout vertical
const int topY = 10;
const int topHeight = 110;
const int bottomY = 130;
const int bottomHeight = 110;
const int segmentHeight = 5;
const int segmentGap = 2;
unsigned long lastFlicker = 0;
// ---------------------------
// PALETTE 26 COULEURS VIVES
// ---------------------------
uint16_t colColor[numCols];
uint16_t makeColor(int i) {
float t = (float)i / numCols;
int R = sin(t * 6.28 + 0) * 127 + 128;
int G = sin(t * 6.28 + 2.09) * 127 + 128;
int B = sin(t * 6.28 + 4.18) * 127 + 128;
return tft.color565(R, G, B);
}
// ---------------------------
// SCINTILLEMENT LED RÉALISTE
// ---------------------------
uint16_t flickerColor(uint16_t baseColor) {
uint8_t r = (baseColor >> 11) & 0x1F;
uint8_t g = (baseColor >> 5) & 0x3F;
uint8_t b = baseColor & 0x1F;
float factor = 0.95 + (random(0, 10) / 100.0);
r = constrain((int)(r * factor), 0, 31);
g = constrain((int)(g * factor), 0, 63);
b = constrain((int)(b * factor), 0, 31);
return (r << 11) | (g << 5) | b;
}
// ---------------------------
// SEGMENT LED + NÉON
// ---------------------------
void drawSegment(int x, int y, int h, uint16_t color) {
uint16_t finalColor = color;
if (millis() - lastFlicker > 80) {
finalColor = flickerColor(color);
}
tft.fillRect(x, y, colWidth, h, finalColor);
uint16_t glow = tft.color565(255, 255, 255);
tft.drawFastHLine(x, y, colWidth, glow);
tft.drawFastHLine(x, y + h - 1, colWidth, glow);
}
// ---------------------------
// COLONNE UNIQUE (haut ou bas)
// ---------------------------
void drawColumn(int x, int value, int peak, int startY, int maxH, uint16_t color, bool mirror) {
int h = map(value, 0, 1023, 0, maxH);
tft.fillRect(x, startY, colWidth, maxH, ST77XX_BLACK);
int segments = h / (segmentHeight + segmentGap);
for (int i = 0; i < segments; i++) {
int pos = i * (segmentHeight + segmentGap);
int y = mirror
? (startY + pos)
: (startY + maxH - pos - segmentHeight);
drawSegment(x, y, segmentHeight, color);
}
if (!mirror) {
int peakY = maxH - map(peak, 0, 1023, 0, maxH);
tft.fillRect(x, startY + peakY, colWidth, 3, ST77XX_WHITE);
}
}
// ---------------------------
// LECTURE MSGEQ7 (64 bandes)
// ---------------------------
void readMSGEQ7() {
digitalWrite(RESET, HIGH);
delayMicroseconds(1);
digitalWrite(RESET, LOW);
for (int i = 0; i < numCols; i++) {
digitalWrite(STROBE, LOW);
delayMicroseconds(25);
leftBands[i] = analogRead(LEFT_IN);
rightBands[i] = analogRead(RIGHT_IN);
digitalWrite(STROBE, HIGH);
delayMicroseconds(25);
}
}
// ---------------------------
// SETUP
// ---------------------------
void setup() {
tft.init(240, 320);
tft.setRotation(1);
tft.fillScreen(ST77XX_BLACK);
pinMode(STROBE, OUTPUT);
pinMode(RESET, OUTPUT);
digitalWrite(RESET, LOW);
digitalWrite(STROBE, HIGH);
randomSeed(analogRead(A3));
for (int i = 0; i < numCols; i++) {
colColor[i] = makeColor(i);
}
}
// ---------------------------
// LOOP
// ---------------------------
void loop() {
readMSGEQ7();
for (int i = 0; i < numCols; i++) {
if (leftBands[i] > peakL[i]) peakL[i] = leftBands[i];
else peakL[i] -= 8;
if (rightBands[i] > peakR[i]) peakR[i] = rightBands[i];
else peakR[i] -= 8;
int x = baseX + i * (colWidth + colSpace);
drawColumn(x, leftBands[i], peakL[i], topY, topHeight, colColor[i], false);
drawColumn(x, rightBands[i], peakR[i], bottomY, bottomHeight, colColor[i], true);
}
if (millis() - lastFlicker > 80) {
lastFlicker = millis();
}
}

