#include <LedControl.h>
// MAX7219 modülü için pinler
#define DIN 12
#define CS 11
#define CLK 10
// LedControl kütüphanesini başlat
LedControl lc = LedControl(DIN, CLK, CS, 1); // DataIn, CLK, LOAD, cihaz sayısı
// Joystick değerleri
int VRx_deger=0; // joystick X eksenindeki potansiyometre digital değeri
int VRy_deger=0; // joystick y eksenindeki potansiyometre digital değeri
void setup() {
Serial.begin(9600); // seri portu 9600 baud rate de başlat
lc.shutdown(0, false); // MAX7219'ü uyandır
lc.setIntensity(0, 15); // Parlaklığı ayarla (0 min, 15 max)
lc.clearDisplay(0); // Display'i temizle
}
void loop() {
// Joystick değerlerini oku
VRx_deger=analogRead(A0); // analog 0 portunu oku
VRy_deger=analogRead(A1); // analog 1 portunu oku
// Joystick değerlerini LED Matriksine endeksle (0-7)
int x = map(VRx_deger, 0, 1023, 7, 0);
int y = map(VRy_deger, 0, 1023, 0, 7);
// Önceki pozisyonu temizle
lc.clearDisplay(0);
// Yeni pozisyonu göster
lc.setLed(0, x, y, true);
// x ve y değerlerini serialcom'da göster
Serial.print("X: ");
Serial.print(x);
Serial.print(" | Y: ");
Serial.println(y);
delay(50);
}