![]() |
Bouncing Balls on Arduino Uno R4 WIFI board with on board 12x8 LED Matrix with Code |
The Arduino UNO R4 WiFi Board has a built-in 12x8 LED Matrix that can be programmed to display graphics and animations, act as an interface, or even play games.
About Arduino Uno R4 WIFI board and Frequently Asked questions - Click here
Steps to Upload Code on Arduino Uno R4 WIFI
- Connect the Arduino Uno R4 WiFi Board: Connect your Arduino Uno R4 WiFi Board to your computer using a USB cable. Ensure that the board is properly connected and recognized by your computer.
- Open the Arduino IDE: Launch the Arduino IDE that you installed in step 1. The IDE provides an interface for writing, compiling, and uploading code to your Arduino board.
- Select the Board and Port: In the Arduino IDE, go to the "Tools" menu and select the appropriate board from the "Board" submenu. In this case, choose "Arduino Uno WiFi Rev2" as the board. Then, go to the "Port" submenu and select the port to which your Arduino Uno R4 WiFi Board is connected. The port will typically have the name of your Arduino board.
- Write or open your code: Now, you can either write your code directly in the Arduino IDE or open an existing code file. To start a new sketch, click on "File" and select "New". This will open a new sketch window where you can write your code.
- Upload the code: Once your code is ready, click on the "Upload" button (an arrow pointing to the right) in the Arduino IDE. The IDE will compile your code and then upload it to the Arduino Uno R4 WiFi Board. You will see the upload progress in the status bar at the bottom of the IDE.
- Verify the upload: After the upload is complete, you should see a "Done uploading" message in the IDE. The code is now running on your Arduino Uno R4 WiFi Board.
- Verify the functionality: If your code includes any output or interaction, such as blinking an LED or communicating with other devices, verify that the functionality is working as expected.
That's it! You have successfully uploaded code to your Arduino Uno R4 WiFi Board. You can modify and upload new code as needed by repeating these steps.
Bouncing Balls sketch on Arduino Uno R4 WIFI Board with on board12x8 LED Matrix.
Watch YouTube Video
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 | #include "Arduino_LED_Matrix.h"
#define MAX_X 12
#define MAX_Y 8
uint8_t grid[MAX_Y][MAX_X] = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
};
ArduinoLEDMatrix matrix;
#define DELAY 20
#define MAX_POINTS 4
struct point_t {
double x, y, dx, dy;
point_t() : x(0,0), y(0,0), dx(0,0), dy(0,0) {}
point_t(int _x, int _y, int _dx, int _dy) :
x(_x), y(_y), dx(_dx), dy(_dy) {}
point_t(double _x, double _y, double _dx, double _dy) :
x(_x), y(_y), dx(_dx), dy(_dy) {}
void set() { [(int) y][(int) x] = 1; }
void reset() { grid[(int) y][(int) x] = 0; }
void update() {
if ((x+dx) < 0 || (x-dx) < 0 || (x+dx) >= MAX_X || (x-dx) >= MAX_X) {
dx *= -1;
}
if ((y+dy) < 0 || (y-dy) < 0 || (y+dy) >= MAX_Y || (y-dy) >= MAX_Y) {
dy *= -1;
}
x += dx;
y += dy;
}
} points[MAX_POINTS];
void setup() {
delay(1000);
Serial.begin(115200);
delay(1000);
Serial.println("Arduino LED Matrix");
matrix.begin();
pinMode(A0, INPUT);
randomSeed(analogRead(A0));
int const min_num = 2;
int const max_num = 4;
auto rand_lambda = []() -> double {
return (1.0 / (double) random(min_num, max_num));
};
for (point_t &pt : points) {
pt.x = random(0, MAX_X);
pt.y = random(0, MAX_Y);
pt.dx = random(2) ? -rand_lambda() : +rand_lambda();
pt.dy = random(2) ? -rand_lambda() : +rand_lambda();
}
}
void loop() {
for (point_t &pt : points) { pt.set(); }
matrix.renderBitmap(grid, 8, 12);
delay(DELAY);
for (point_t &pt : points) { pt.reset(); }
matrix.renderBitmap(grid, 8, 12);
for (point_t &pt : points) { pt.update(); }
}
|
Code to first load a smiley face on 12x8 Arduino uno R4 wifi Board matrix, and then change it to a heart.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 | #include "Arduino_LED_Matrix.h"
ArduinoLEDMatrix matrix;
void setup() {
Serial.begin(115200);
matrix.begin();
}
const uint32_t happy[] = {
0x19819,
0x80000001,
0x81f8000
};
const uint32_t heart[] = {
0x3184a444,
0x44042081,
0x100a0040
};
void loop(){
matrix.loadFrame(happy);
delay(500);
matrix.loadFrame(heart);
delay(500);
}
|
Thank You!
Have a Great Day!
Happy Learning!