Kostenloser Versand ab €74,95 NL

Vor 16:00 bestelt = Heute versendet

Schnelle Lieferung mit DHL

XNUMX Tage Rückgaberecht *


Land

Mit diesem Projekt zeige ich, wie Sie einen Ball auf einer 8 × 8 LED-Matrix steuern können.

Mit den beiden Potentiometern können Sie den Ball über die X- und Y-Achse der Matrix bewegen. 

In diesem Projekt lernen Sie, wie Sie eine LED-Matrix verwenden und die Werte eines Potentiometers ablesen.

  • Level - Anfänger / Mittelstufe 40% 40%
  • Dauer - 45/60 min 60% 60%
  • Kosten - 36,51 € abgeschlossen 30% 30%

Schritt 1: Anforderungen

Schritt 2: Bauen und Verkabeln

Jetzt, da Sie alle Teile haben, können Sie mit dem Verbinden der Teile beginnen. Zuerst geht man von den 5V am UNO zum Plus am Brotboard und vom GND zum Minus auf dem Brotboard† Sobald Sie das getan haben, legen Sie die Potentiometer auf das Brotboard† Dann nehmen Sie den ganz linken Pin beider Potentiometer und verbinden ihn mit dem Plus, den ganz rechten Pin mit dem Minus und den mittleren von einem Potentiometer verbinden Sie mit dem A0 und dem anderen mit dem A1. Jetzt werden wir die LED-Matrix anschließen, die LED-Metrix in das Brot legenboard mit dem Chip auf der Unterseite. Der VCC der LED-Matrix geht nach Plus und der GND geht nach Minus.Dann verbinden wir die I / O-Pins mit den drei anderen Pins der Matrix. DIN geht an Pin 12, CS an Pin 10 und CLK an Pin 11.

Schritt 3: Programmierung

 

Wenn alles richtig angeschlossen ist, können Sie mit dem Schreiben des Programms beginnen.

Es ist ein ziemlich großes Programm, aber es ist hauptsächlich konstant mit nur wenigen Werten, die sich ändern.

Dieser Code wird jetzt für eine LED-Matrix erstellt, die nur eine X- und eine Y-Achse hat.

Wenn Sie auch eine Z-Achse verwenden möchten, müssen Sie ein zusätzliches Potentiometer anschließen und dann den Code so einstellen, dass die Werte gelesen werden können.

 Sie können den folgenden Code kopieren. Wir empfehlen jedoch, ihn selbst einzugeben, wenn Sie mehr darüber erfahren.

#include LedControl.h

// hier geben wir der LED-Matrix einen Namen und die E / A-Pins, die sie steuern kann

LedControl L = LedControl (12, 11, 10);

// hier definieren wir die Potentiometer

const int jar = 0;

konstant int pot2 = 1;

// hier stellen wir sicher, dass wir die Werte des Potentiometers speichern können

int potwert;

int potwert2;

 

void setup () {

  // hier setzen wir die LED-Matrix, indem wir sie ausschalten, dann die Intensität anpassen und den Speicher löschen

  L. Shutdown (0, falsch);

  L.setIntensity (0, 4);

  L.clearDisplay (0);

}

 

void loop () {

  // hier sagen wir, dass der Arduino die analogen Ports für Werte lesen sollte

  potvalue = analogRead (Topf);

  // hier definieren wir die Werte, die der Topfzähler anzeigen kann

  potvalue = map (potvalue, 0, 1000, 0, 7);

  potvalue2 = analogRead (pot2);

  potvalue2 = map (potvalue2, 0, 1000, 0, 7);

  // hier prüfen wir, ob beide Werte gleich 0 sind, wenn ja Licht 0,0 aufleuchtet

  // Wenn also 1 und 2 gleich 0 sind, wird 0,0 eingeschaltet

  if (potvalue == 0 && potvalue2 == 0) {

    int-Reihe = 0;

    int spalte = 0;

    L.setLed (0, row, col, true);

  }

  // hier schauen wir, ob einer dieser Werte nicht 0 ist, wenn true 0,0 ausgeht

  // Wir wiederholen diesen Vorgang die ganze Zeit, bis alle Koordinaten definiert sind

  // Was hier steht, ist, wenn 1 oder 2 nicht gleich 0 ist, dann geht 0,0 aus

  if (potvalue! = 0 || potvalue2! = 0) {

    int-Reihe = 0;

    int spalte = 0;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 1 && potvalue2 == 0) {

    int-Reihe = 1;

    int spalte = 0;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 1 || potvalue2! = 0) {

    int-Reihe = 1;

    int spalte = 0;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 2 && potvalue2 == 0) {

    int-Reihe = 2;

    int spalte = 0;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 2 || potvalue2! = 0) {

    int-Reihe = 2;

    int spalte = 0;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 3 && potvalue2 == 0) {

    int-Reihe = 3;

    int spalte = 0;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 3 || potvalue2! = 0) {

    int-Reihe = 3;

    int spalte = 0;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 4 && potvalue2 == 0) {

    int-Reihe = 4;

    int spalte = 0;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 4 || potvalue2! = 0) {

    int-Reihe = 4;

    int spalte = 0;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 5 && potvalue2 == 0) {

    int-Reihe = 5;

    int spalte = 0;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 5 || potvalue2! = 0) {

    int-Reihe = 5;

    int spalte = 0;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 6 && potvalue2 == 0) {

    int-Reihe = 6;

    int spalte = 0;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 6 || potvalue2! = 0) {

    int-Reihe = 6;

    int spalte = 0;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 7 && potvalue2 == 0) {

    int-Reihe = 7;

    int spalte = 0;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 7 || potvalue2! = 0) {

    int-Reihe = 7;

    int spalte = 0;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 0 && potvalue2 == 1) {

    int-Reihe = 0;

    int spalte = 1;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 0 || potvalue2! = 1) {

    int-Reihe = 0;

    int spalte = 1;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 1 && potvalue2 == 1) {

    int-Reihe = 1;

    int spalte = 1;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 1 || potvalue2! = 1) {

    int-Reihe = 1;

    int spalte = 1;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 2 && potvalue2 == 1) {

    int-Reihe = 2;

    int spalte = 1;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 2 || potvalue2! = 1) {

    int-Reihe = 2;

    int spalte = 1;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 3 && potvalue2 == 1) {

    int-Reihe = 3;

    int spalte = 1;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 3 || potvalue2! = 1) {

    int-Reihe = 3;

    int spalte = 1;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 4 && potvalue2 == 1) {

    int-Reihe = 4;

    int spalte = 1;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 4 || potvalue2! = 1) {

    int-Reihe = 4;

    int spalte = 1;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 5 && potvalue2 == 1) {

    int-Reihe = 5;

    int spalte = 1;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 5 || potvalue2! = 1) {

    int-Reihe = 5;

    int spalte = 1;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 6 && potvalue2 == 1) {

    int-Reihe = 6;

    int spalte = 1;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 6 || potvalue2! = 1) {

    int-Reihe = 6;

    int spalte = 1;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 7 && potvalue2 == 1) {

    int-Reihe = 7;

    int spalte = 1;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 7 || potvalue2! = 1) {

    int-Reihe = 7;

    int spalte = 1;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 0 && potvalue2 == 2) {

    int-Reihe = 0;

    int spalte = 2;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 0 || potvalue2! = 2) {

    int-Reihe = 0;

    int spalte = 2;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 1 && potvalue2 == 2) {

    int-Reihe = 1;

    int spalte = 2;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 1 || potvalue2! = 2) {

    int-Reihe = 1;

    int spalte = 2;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 2 && potvalue2 == 2) {

    int-Reihe = 2;

    int spalte = 2;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 2 || potvalue2! = 2) {

    int-Reihe = 2;

    int spalte = 2;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 3 && potvalue2 == 2) {

    int-Reihe = 3;

    int spalte = 2;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 3 || potvalue2! = 2) {

    int-Reihe = 3;

    int spalte = 2;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 4 && potvalue2 == 2) {

    int-Reihe = 4;

    int spalte = 2;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 4 || potvalue2! = 2) {

    int-Reihe = 4;

    int spalte = 2;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 5 && potvalue2 == 2) {

    int-Reihe = 5;

    int spalte = 2;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 5 || potvalue2! = 2) {

    int-Reihe = 5;

    int spalte = 2;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 6 && potvalue2 == 2) {

    int-Reihe = 6;

    int spalte = 2;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 6 || potvalue2! = 2) {

    int-Reihe = 6;

    int spalte = 2;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 7 && potvalue2 == 2) {

    int-Reihe = 7;

    int spalte = 2;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 7 || potvalue2! = 2) {

    int-Reihe = 7;

    int spalte = 2;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 0 && potvalue2 == 3) {

    int-Reihe = 0;

    int spalte = 3;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 0 || potvalue2! = 3) {

    int-Reihe = 0;

    int spalte = 3;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 1 && potvalue2 == 3) {

    int-Reihe = 1;

    int spalte = 3;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 1 || potvalue2! = 3) {

    int-Reihe = 1;

    int spalte = 3;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 2 && potvalue2 == 3) {

    int-Reihe = 2;

    int spalte = 3;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 2 || potvalue2! = 3) {

    int-Reihe = 2;

    int spalte = 3;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 3 && potvalue2 == 3) {

    int-Reihe = 3;

    int spalte = 3;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 3 || potvalue2! = 3) {

    int-Reihe = 3;

    int spalte = 3;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 4 && potvalue2 == 3) {

    int-Reihe = 4;

    int spalte = 3;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 4 || potvalue2! = 3) {

    int-Reihe = 4;

    int spalte = 3;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 5 && potvalue2 == 3) {

    int-Reihe = 5;

    int spalte = 3;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 5 || potvalue2! = 3) {

    int-Reihe = 5;

    int spalte = 3;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 6 && potvalue2 == 3) {

    int-Reihe = 6;

    int spalte = 3;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 6 || potvalue2! = 3) {

    int-Reihe = 6;

    int spalte = 3;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 7 && potvalue2 == 3) {

    int-Reihe = 7;

    int spalte = 3;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 7 || potvalue2! = 3) {

    int-Reihe = 7;

    int spalte = 3;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 0 && potvalue2 == 4) {

    int-Reihe = 0;

    int spalte = 4;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 0 || potvalue2! = 4) {

    int-Reihe = 0;

    int spalte = 4;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 1 && potvalue2 == 4) {

    int-Reihe = 1;

    int spalte = 4;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 1 || potvalue2! = 4) {

    int-Reihe = 1;

    int spalte = 4;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 2 && potvalue2 == 4) {

    int-Reihe = 2;

    int spalte = 4;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 2 || potvalue2! = 4) {

    int-Reihe = 2;

    int spalte = 4;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 3 && potvalue2 == 4) {

    int-Reihe = 3;

    int spalte = 4;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 3 || potvalue2! = 4) {

    int-Reihe = 3;

    int spalte = 4;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 4 && potvalue2 == 4) {

    int-Reihe = 4;

    int spalte = 4;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 4 || potvalue2! = 4) {

    int-Reihe = 4;

    int spalte = 4;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 5 && potvalue2 == 4) {

    int-Reihe = 5;

    int spalte = 4;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 5 || potvalue2! = 4) {

    int-Reihe = 5;

    int spalte = 4;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 6 && potvalue2 == 4) {

    int-Reihe = 6;

    int spalte = 4;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 6 || potvalue2! = 4) {

    int-Reihe = 6;

    int spalte = 4;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 7 && potvalue2 == 4) {

    int-Reihe = 7;

    int spalte = 4;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 7 || potvalue2! = 4) {

    int-Reihe = 7;

    int spalte = 4;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 0 && potvalue2 == 5) {

    int-Reihe = 0;

    int spalte = 5;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 0 || potvalue2! = 5) {

    int-Reihe = 0;

    int spalte = 5;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 1 && potvalue2 == 5) {

    int-Reihe = 1;

    int spalte = 5;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 1 || potvalue2! = 5) {

    int-Reihe = 1;

    int spalte = 5;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 2 && potvalue2 == 5) {

    int-Reihe = 2;

    int spalte = 5;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 2 || potvalue2! = 5) {

    int-Reihe = 2;

    int spalte = 5;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 3 && potvalue2 == 5) {

    int-Reihe = 3;

    int spalte = 5;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 3 || potvalue2! = 5) {

    int-Reihe = 3;

    int spalte = 5;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 4 && potvalue2 == 5) {

    int-Reihe = 4;

    int spalte = 5;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 4 || potvalue2! = 5) {

    int-Reihe = 4;

    int spalte = 5;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 5 && potvalue2 == 5) {

    int-Reihe = 5;

    int spalte = 5;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 5 || potvalue2! = 5) {

    int-Reihe = 5;

    int spalte = 5;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 6 && potvalue2 == 5) {

    int-Reihe = 6;

    int spalte = 5;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 6 || potvalue2! = 5) {

    int-Reihe = 6;

    int spalte = 5;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 7 && potvalue2 == 5) {

    int-Reihe = 7;

    int spalte = 5;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 7 || potvalue2! = 5) {

    int-Reihe = 7;

    int spalte = 5;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 0 && potvalue2 == 6) {

    int-Reihe = 0;

    int spalte = 6;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 0 || potvalue2! = 6) {

    int-Reihe = 0;

    int spalte = 6;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 1 && potvalue2 == 6) {

    int-Reihe = 1;

    int spalte = 6;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 1 || potvalue2! = 6) {

    int-Reihe = 1;

    int spalte = 6;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 2 && potvalue2 == 6) {

    int-Reihe = 2;

    int spalte = 6;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 2 || potvalue2! = 6) {

    int-Reihe = 2;

    int spalte = 6;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 3 && potvalue2 == 6) {

    int-Reihe = 3;

    int spalte = 6;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 3 || potvalue2! = 6) {

    int-Reihe = 3;

    int spalte = 6;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 4 && potvalue2 == 6) {

    int-Reihe = 4;

    int spalte = 6;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 4 || potvalue2! = 6) {

    int-Reihe = 4;

    int spalte = 6;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 5 && potvalue2 == 6) {

    int-Reihe = 5;

    int spalte = 6;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 5 || potvalue2! = 6) {

    int-Reihe = 5;

    int spalte = 6;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 6 && potvalue2 == 6) {

    int-Reihe = 6;

    int spalte = 6;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 6 || potvalue2! = 6) {

    int-Reihe = 6;

    int spalte = 6;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 7 && potvalue2 == 6) {

    int-Reihe = 7;

    int spalte = 6;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 7 || potvalue2! = 6) {

    int-Reihe = 7;

    int spalte = 6;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 0 && potvalue2 == 7) {

    int-Reihe = 0;

    int spalte = 7;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 0 || potvalue2! = 7) {

    int-Reihe = 0;

    int spalte = 7;

    L.setLed (0, row, col, false);

  }

  if (potvalue == 1 && potvalue2 == 7) {

    int-Reihe = 1;

    int spalte = 7;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 1 || potvalue2! = 7) {

    int-Reihe = 1;

    int spalte = 7;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 2 && potvalue2 == 7) {

    int-Reihe = 2;

    int spalte = 7;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 2 || potvalue2! = 7) {

    int-Reihe = 2;

    int spalte = 7;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 3 && potvalue2 == 7) {

    int-Reihe = 3;

    int spalte = 7;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 3 || potvalue2! = 7) {

    int-Reihe = 3;

    int spalte = 7;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 4 && potvalue2 == 7) {

    int-Reihe = 4;

    int spalte = 7;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 4 || potvalue2! = 7) {

    int-Reihe = 4;

    int spalte = 7;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 5 && potvalue2 == 7) {

    int-Reihe = 5;

    int spalte = 7;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 5 || potvalue2! = 7) {

    int-Reihe = 5;

    int spalte = 7;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 6 && potvalue2 == 7) {

    int-Reihe = 6;

    int spalte = 7;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 6 || potvalue2! = 7) {

    int-Reihe = 6;

    int spalte = 7;

    L.setLed (0, row, col, false);

  }

    if (potvalue == 7 && potvalue2 == 7) {

    int-Reihe = 7;

    int spalte = 7;

    L.setLed (0, row, col, true);

  }

  if (potvalue! = 7 || potvalue2! = 7) {

    int-Reihe = 7;

    int spalte = 7;

    L.setLed (0, row, col, false);

  }

}

Die Bewertung von www.elektronicavoorjou.nl bei WebwinkelKeur-Bewertungen ist 9.3 / 10 basierend auf 4998 Bewertungen.