Delivery throughout Europe

Ordered before 16:00 = Shipped today

Fast delivery with DHL

XNUMX days return *


Country

With this project I show how you can control a ball on an 8 × 8 LED matrix.

With the two potentiometers you can move the ball over the X and Y axis of the matrix. 

In this project you will learn how to use an LED matrix and how to read the values ​​of a potentiometer.

  • Level - Beginner / Intermediate 40% 40%
  • Duration - 45/60 Min 60% 60%
  • Costs - € 36,51 euros complete 30% 30%

Step 1: Requirements

Step 2: Building and Wiring

Now that you have all the parts you can start connecting the parts. First you go from the 5V on the UNO to the plus on the breadboard and from the GND to the minus on the breadboard† Once you've done that put the potentiometers on the breadboard† Then you take the leftmost pin of both potentiometers and connect it to the plus, the rightmost pin to the minus and the middle of one potentiometer you connect to the A0 and the other to the A1. Now we are going to connect the led matrix, put the led metrix in the breadboard with the chip on the bottom. The VCC of the led matrix goes to the plus and the GND goes to the minus. Then we connect the I/O pins to the three other pins on the matrix. The DIN goes to pin 12, the CS to pin 10 and the CLK to pin 11.

Step 3: Programming

 

If everything is connected correctly you can start writing the program.

It is a fairly large program but is mainly constant with only a few values ​​that change.

This code is now made for an LED matrix that only has an X and Y axis.

If you also want to use a Z axis you have to connect an extra potentiometer and then adjust the code so that the values ​​can be read.

 You can copy the code below, but we recommend typing it yourself as you learn more from this.

#include LedControl.h

// here we give the LED matrix a name and the I / O pins that it can control

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

// here we define the potentiometers

const int jar = 0;

const int pot2 = 1;

// here we make sure that we can store the values ​​of the potentiometer

int potvalue;

int jarvalue2;

 

void setup () {

  // here we set the led matrix by turning it off then adjust the intensity and clear the memory

  L.shutdown (0, false);

  L.setIntensity (0, 4);

  L.clearDisplay (0);

}

 

void loop () {

  // here we say that the Arduino should read the analog ports for values

  potvalue = analogRead (pot);

  // here we define the values ​​that the pot meter can indicate

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

  potvalue2 = analogRead (pot2);

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

  // here we check if both values ​​are equal to 0 if yes light 0,0 comes on

  // so what is actually here is if 1 and 2 are equal to 0 then 0,0 will be turned on

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

    int row = 0;

    int col = 0;

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

  }

  // here we look if one of those values ​​is not 0 if that is true 0,0 goes out

  // we keep repeating this process all the time until all coordinates are defined

  // what it says here is if 1 or 2 is not equal to 0 then 0,0 goes out

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

    int row = 0;

    int col = 0;

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

  }

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

    int row = 1;

    int col = 0;

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

  }

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

    int row = 1;

    int col = 0;

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

  }

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

    int row = 2;

    int col = 0;

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

  }

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

    int row = 2;

    int col = 0;

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

  }

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

    int row = 3;

    int col = 0;

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

  }

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

    int row = 3;

    int col = 0;

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

  }

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

    int row = 4;

    int col = 0;

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

  }

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

    int row = 4;

    int col = 0;

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

  }

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

    int row = 5;

    int col = 0;

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

  }

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

    int row = 5;

    int col = 0;

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

  }

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

    int row = 6;

    int col = 0;

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

  }

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

    int row = 6;

    int col = 0;

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

  }

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

    int row = 7;

    int col = 0;

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

  }

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

    int row = 7;

    int col = 0;

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

  }

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

    int row = 0;

    int col = 1;

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

  }

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

    int row = 0;

    int col = 1;

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

  }

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

    int row = 1;

    int col = 1;

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

  }

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

    int row = 1;

    int col = 1;

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

  }

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

    int row = 2;

    int col = 1;

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

  }

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

    int row = 2;

    int col = 1;

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

  }

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

    int row = 3;

    int col = 1;

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

  }

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

    int row = 3;

    int col = 1;

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

  }

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

    int row = 4;

    int col = 1;

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

  }

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

    int row = 4;

    int col = 1;

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

  }

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

    int row = 5;

    int col = 1;

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

  }

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

    int row = 5;

    int col = 1;

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

  }

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

    int row = 6;

    int col = 1;

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

  }

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

    int row = 6;

    int col = 1;

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

  }

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

    int row = 7;

    int col = 1;

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

  }

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

    int row = 7;

    int col = 1;

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

  }

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

    int row = 0;

    int col = 2;

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

  }

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

    int row = 0;

    int col = 2;

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

  }

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

    int row = 1;

    int col = 2;

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

  }

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

    int row = 1;

    int col = 2;

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

  }

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

    int row = 2;

    int col = 2;

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

  }

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

    int row = 2;

    int col = 2;

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

  }

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

    int row = 3;

    int col = 2;

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

  }

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

    int row = 3;

    int col = 2;

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

  }

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

    int row = 4;

    int col = 2;

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

  }

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

    int row = 4;

    int col = 2;

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

  }

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

    int row = 5;

    int col = 2;

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

  }

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

    int row = 5;

    int col = 2;

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

  }

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

    int row = 6;

    int col = 2;

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

  }

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

    int row = 6;

    int col = 2;

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

  }

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

    int row = 7;

    int col = 2;

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

  }

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

    int row = 7;

    int col = 2;

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

  }

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

    int row = 0;

    int col = 3;

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

  }

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

    int row = 0;

    int col = 3;

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

  }

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

    int row = 1;

    int col = 3;

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

  }

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

    int row = 1;

    int col = 3;

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

  }

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

    int row = 2;

    int col = 3;

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

  }

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

    int row = 2;

    int col = 3;

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

  }

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

    int row = 3;

    int col = 3;

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

  }

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

    int row = 3;

    int col = 3;

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

  }

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

    int row = 4;

    int col = 3;

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

  }

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

    int row = 4;

    int col = 3;

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

  }

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

    int row = 5;

    int col = 3;

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

  }

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

    int row = 5;

    int col = 3;

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

  }

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

    int row = 6;

    int col = 3;

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

  }

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

    int row = 6;

    int col = 3;

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

  }

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

    int row = 7;

    int col = 3;

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

  }

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

    int row = 7;

    int col = 3;

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

  }

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

    int row = 0;

    int col = 4;

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

  }

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

    int row = 0;

    int col = 4;

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

  }

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

    int row = 1;

    int col = 4;

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

  }

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

    int row = 1;

    int col = 4;

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

  }

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

    int row = 2;

    int col = 4;

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

  }

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

    int row = 2;

    int col = 4;

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

  }

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

    int row = 3;

    int col = 4;

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

  }

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

    int row = 3;

    int col = 4;

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

  }

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

    int row = 4;

    int col = 4;

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

  }

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

    int row = 4;

    int col = 4;

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

  }

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

    int row = 5;

    int col = 4;

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

  }

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

    int row = 5;

    int col = 4;

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

  }

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

    int row = 6;

    int col = 4;

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

  }

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

    int row = 6;

    int col = 4;

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

  }

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

    int row = 7;

    int col = 4;

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

  }

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

    int row = 7;

    int col = 4;

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

  }

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

    int row = 0;

    int col = 5;

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

  }

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

    int row = 0;

    int col = 5;

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

  }

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

    int row = 1;

    int col = 5;

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

  }

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

    int row = 1;

    int col = 5;

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

  }

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

    int row = 2;

    int col = 5;

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

  }

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

    int row = 2;

    int col = 5;

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

  }

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

    int row = 3;

    int col = 5;

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

  }

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

    int row = 3;

    int col = 5;

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

  }

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

    int row = 4;

    int col = 5;

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

  }

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

    int row = 4;

    int col = 5;

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

  }

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

    int row = 5;

    int col = 5;

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

  }

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

    int row = 5;

    int col = 5;

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

  }

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

    int row = 6;

    int col = 5;

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

  }

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

    int row = 6;

    int col = 5;

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

  }

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

    int row = 7;

    int col = 5;

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

  }

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

    int row = 7;

    int col = 5;

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

  }

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

    int row = 0;

    int col = 6;

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

  }

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

    int row = 0;

    int col = 6;

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

  }

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

    int row = 1;

    int col = 6;

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

  }

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

    int row = 1;

    int col = 6;

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

  }

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

    int row = 2;

    int col = 6;

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

  }

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

    int row = 2;

    int col = 6;

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

  }

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

    int row = 3;

    int col = 6;

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

  }

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

    int row = 3;

    int col = 6;

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

  }

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

    int row = 4;

    int col = 6;

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

  }

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

    int row = 4;

    int col = 6;

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

  }

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

    int row = 5;

    int col = 6;

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

  }

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

    int row = 5;

    int col = 6;

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

  }

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

    int row = 6;

    int col = 6;

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

  }

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

    int row = 6;

    int col = 6;

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

  }

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

    int row = 7;

    int col = 6;

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

  }

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

    int row = 7;

    int col = 6;

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

  }

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

    int row = 0;

    int col = 7;

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

  }

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

    int row = 0;

    int col = 7;

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

  }

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

    int row = 1;

    int col = 7;

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

  }

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

    int row = 1;

    int col = 7;

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

  }

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

    int row = 2;

    int col = 7;

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

  }

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

    int row = 2;

    int col = 7;

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

  }

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

    int row = 3;

    int col = 7;

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

  }

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

    int row = 3;

    int col = 7;

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

  }

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

    int row = 4;

    int col = 7;

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

  }

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

    int row = 4;

    int col = 7;

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

  }

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

    int row = 5;

    int col = 7;

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

  }

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

    int row = 5;

    int col = 7;

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

  }

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

    int row = 6;

    int col = 7;

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

  }

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

    int row = 6;

    int col = 7;

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

  }

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

    int row = 7;

    int col = 7;

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

  }

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

    int row = 7;

    int col = 7;

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

  }

}

The rating of www.elektronicavoorjou.nl at WebwinkelKeur Reviews is 9.3/10 based on 4998 reviews.