Skip to content

Add comments #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions libraries/AnalogWave/examples/SineWave/SineWave.ino
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
#include "analogWave.h"
/*
SineWave

analogWave wave(DAC);
Generates a pre-generated sawtooth-waveform.

See the full documentatio here:
https://docs.arduino.cc/tutorials/uno-r4-wifi/dac
*/

#include "analogWave.h" // Include the library for analog waveform generation

analogWave wave(DAC); // Create an instance of the analogWave class, using the DAC pin

int freq = 10; // in hertz, change accordingly

void setup() {
Serial.begin(115200);
wave.sine(freq);
Serial.begin(115200); // Initialize serial communication at a baud rate of 115200
wave.sine(freq); // Generate a sine wave with the initial frequency
}

void loop() {
// Read an analog value from pin A5 and map it to a frequency range
freq = map(analogRead(A5), 0, 1024, 0, 10000);

// Print the updated frequency to the serial monitor
Serial.println("Frequency is now " + String(freq) + " hz");
wave.freq(freq);
delay(1000);

wave.freq(freq); // Set the frequency of the waveform generator to the updated value
delay(1000); // Delay for one second before repeating
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
#include "Arduino_LED_Matrix.h"
#include "frames.h"
/*
Single Frame

ArduinoLEDMatrix matrix;
Displays single frames using matrix.loadFrame

See the full documentation here:
https://docs.arduino.cc/tutorials/uno-r4-wifi/led-matrix
*/

#include "Arduino_LED_Matrix.h" // Include the library for controlling LED matrix
#include "frames.h" // Include a header file containing frame data

ArduinoLEDMatrix matrix; // Create an instance of the ArduinoLEDMatrix class

void setup() {
Serial.begin(115200);
matrix.begin();
}
Serial.begin(115200); // Initialize serial communication at a baud rate of 115200
matrix.begin(); // Initialize the LED matrix
}

void loop() {
// Load and display the "chip" frame on the LED matrix
matrix.loadFrame(chip);
delay(500);
delay(500); // Pause for 500 milliseconds (half a second)

// Load and display the "happy" frame on the LED matrix
matrix.loadFrame(danger);
delay(500);
delay(500); // Pause for 500 milliseconds (half a second)

// Load and display the "happy" frame on the LED matrix
matrix.loadFrame(happy);
delay(500);
delay(500); // Pause for 500 milliseconds (half a second)

// Load and display the "heart" frame on the LED matrix
matrix.loadFrame(heart);
delay(500);
delay(500); // Pause for 500 milliseconds (half a second)

// Print the current value of millis() to the serial monitor
Serial.println(millis());
}
10 changes: 10 additions & 0 deletions libraries/Arduino_LED_Matrix/examples/GameOfLife/GameOfLife.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
/*
Game Of Life

The Game of Life, also known simply as Life, is a cellular automaton devised
by the British mathematician John Horton Conway in 1970. It is a zero-player game,
meaning that its evolution is determined by its initial state, requiring no further
input.

Example developed starting from Toby Oxborrow's sketch
https://github.com/tobyoxborrow/gameoflife-arduino/blob/master/GameOfLife.ino

See the full documentation here:
https://docs.arduino.cc/tutorials/uno-r4-wifi/led-matrix
*/

#include "Arduino_LED_Matrix.h"
Expand Down
19 changes: 13 additions & 6 deletions libraries/Arduino_LED_Matrix/examples/LivePreview/LivePreview.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,34 @@
The LED Matrix editor is part of Arduino Labs (https://labs.arduino.cc/), and is therefore considered experimental software.

Don't forget to close any serial monitor already opened.

See the full documentation here:
https://docs.arduino.cc/tutorials/uno-r4-wifi/led-matrix
*/

#include "Arduino_LED_Matrix.h"
#include "Arduino_LED_Matrix.h" // Include the library for controlling LED matrix

ArduinoLEDMatrix matrix;
ArduinoLEDMatrix matrix; // Create an instance of the ArduinoLEDMatrix class

void setup() {
Serial.begin(115200);
matrix.begin();
Serial.begin(115200); // Initialize serial communication at a baud rate of 115200
matrix.begin(); // Initialize the LED matrix
}

// Define an array to hold pixel data for a single frame (4 pixels)
uint32_t frame[] = {
0, 0, 0, 0xFFFF
};

void loop() {
// Check if there are at least 12 bytes available in the serial buffer
if(Serial.available() >= 12){
// Read 4 bytes from the serial buffer and compose them into a 32-bit value for each element in the frame
frame[0] = Serial.read() | Serial.read() << 8 | Serial.read() << 16 | Serial.read() << 24;
frame[1] = Serial.read() | Serial.read() << 8 | Serial.read() << 16 | Serial.read() << 24;
frame[2] = Serial.read() | Serial.read() << 8 | Serial.read() << 16 | Serial.read() << 24;

// Load and display the received frame data on the LED matrix
matrix.loadFrame(frame);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
/*
Matrix Frame Buffer

This Arduino sketch demonstrates the creation and manipulation of
a frame buffer for the LED matrix. The frame buffer is used to control
the lighting of individual LEDs on the matrix, turning them randomly on and off.

See the full documentation here:
https://docs.arduino.cc/tutorials/uno-r4-wifi/led-matrix
*/

// Include the Arduino_LED_Matrix library
#include "Arduino_LED_Matrix.h"

// Creating an instance of the ArduinoLEDMatrix class
ArduinoLEDMatrix matrix;

// Defining the frame array for the LED matrix with pixel values
uint8_t frame[8][12] = {
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
{ 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0 },
Expand All @@ -12,26 +27,36 @@ uint8_t frame[8][12] = {
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
};

// Setting up time intervals and dimensions for the matrix
unsigned long lastTickTime, lastGameTickTime;
#define UPDATE_INTERVAL 100
#define GAME_UPDATE_INTERVAL 66

#define ROWS 8
#define COLUMNS 12

// Variables to track the current positions
uint8_t pointX = 0, pointY = 0;

void setup() {
// put your setup code here, to run once:
// Initializing serial communication and delaying for setup
Serial.begin(115200);
delay(1500);

// Initializing the LED matrix
matrix.begin();

// Initializing time tracking variables
lastGameTickTime = lastTickTime = millis();
}

void loop() {
// Tracking the current time
unsigned long msNow = millis();

// Updating the game logic with a fixed interval
if (msNow - lastGameTickTime > GAME_UPDATE_INTERVAL) {
// Incrementing pointX and handling wraparound
pointX++;
if (pointX >= COLUMNS) {
pointX = 0;
Expand All @@ -40,14 +65,24 @@ void loop() {
pointY = 0;
}
}

// Generating random positions and pixel value
pointX = random(COLUMNS);
pointY = random(ROWS);
uint8_t pixelValue = random(2);

// Updating the frame with the new pixel value
frame[pointY][pointX] = pixelValue;

// Updating the last game tick time
lastGameTickTime = msNow;
}

// Rendering the LED matrix with the current frame at a fixed interval
if (msNow - lastTickTime > UPDATE_INTERVAL) {
matrix.renderBitmap(frame, 8, 12);

// Updating the last rendering tick time
lastTickTime = msNow;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
/*
Sketch shows animation defined in animation.h
*/

//Include library and animation.h

#include "Arduino_LED_Matrix.h"
#include "animation.h"

ArduinoLEDMatrix matrix;
// Create an instance of the ArduinoLEDMatrix class
ArduinoLEDMatrix matrix;

void setup() {
Serial.begin(115200);
Expand Down