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 all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
created 18 Dec 2018
modified 3 Jul 2023
by Tom Igoe

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

// include the AnalogWave library:
Expand Down
5 changes: 4 additions & 1 deletion libraries/AnalogWave/examples/DACJacques/DACJacques.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
DAC Melody player

Generates a series of tones from MIDI note values
Expand All @@ -14,6 +14,9 @@ circuit:
created 13 Feb 2017
modified 3 Jul 2023
by Tom Igoe

See the full documentation here:
https://docs.arduino.cc/tutorials/uno-r4-wifi/dac
*/
#include "analogWave.h"
analogWave wave(DAC);
Expand Down
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 documentation 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
}
9 changes: 9 additions & 0 deletions libraries/Arduino_CAN/examples/CANRead/CANRead.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
CANRead

Receive and read CAN Bus messages

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

/**************************************************************************************
* INCLUDE
**************************************************************************************/
Expand Down
9 changes: 9 additions & 0 deletions libraries/Arduino_CAN/examples/CANWrite/CANWrite.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
CANWrite

Write and send CAN Bus messages

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

/**************************************************************************************
* INCLUDE
**************************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
The code demonstrates the usage of FreeRTOS (Real-Time Operating System) to run concurrent tasks.

One task is responsible for running the loop() logic (in a thread-safe manner),
while the other task blinks an LED using the built-in LED on non-Portenta boards or
the RGB LED on the Portenta C33 board.
*/

/**************************************************************************************
* INCLUDE
**************************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
#include "Arduino_LED_Matrix.h"
#include "frames.h"
/*
Single Frame

Displays single frames using matrix.loadFrame

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

ArduinoLEDMatrix matrix;
#include "Arduino_LED_Matrix.h" // Include the LED_Matrix library
#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 "danger" frame on the LED matrix
matrix.loadFrame(danger);
delay(500);

// Load and display the "happy" frame on the LED matrix
matrix.loadFrame(happy);
delay(500);

// Load and display the "heart" frame on the LED matrix
matrix.loadFrame(heart);
delay(500);

// Print the current value of millis() to the serial monitor
Serial.println(millis());
}
12 changes: 11 additions & 1 deletion libraries/Arduino_LED_Matrix/examples/GameOfLife/GameOfLife.ino
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
/*
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"
#include "Arduino_LED_Matrix.h" // Include the LED_Matrix library

// grid dimensions. should not be larger than 8x8
#define MAX_Y 8
Expand Down
17 changes: 12 additions & 5 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 LED_Matrix library

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,8 +1,23 @@
#include "Arduino_LED_Matrix.h"
ArduinoLEDMatrix matrix;
/*
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 LED_Matrix library
#include "Arduino_LED_Matrix.h"

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

// Define 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 },
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
{ 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 1, 1, 0, 0, 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 }
};

// Set 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:
// Initialize serial communication and delaying for setup
Serial.begin(115200);
delay(1500);

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

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

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

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

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

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

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

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

// Update the last rendering tick time
lastTickTime = msNow;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

created 26 Jun 2023
by Martino Facchin

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


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
#include "Arduino_LED_Matrix.h"
#include "animation.h"
/*
Play Animation

ArduinoLEDMatrix matrix;
Sketch shows animation defined in animation.h

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



#include "Arduino_LED_Matrix.h" //Include the LED_Matrix library
#include "animation.h" //Include animation.h header file

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

void setup() {
Serial.begin(115200);
Expand Down
14 changes: 9 additions & 5 deletions libraries/EEPROM/examples/eeprom_read/eeprom_read.ino
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
* EEPROM Read
*
* Reads the value of each byte of the EEPROM and prints it
* to the computer.
* This example code is in the public domain.
EEPROM Read

Reads the value of each byte of the EEPROM and prints it
to the computer.
This example code is in the public domain.

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

// Include the EEPROM library
#include <EEPROM.h>

// start reading from the first byte (address 0) of the EEPROM
Expand Down
14 changes: 9 additions & 5 deletions libraries/EEPROM/examples/eeprom_write/eeprom_write.ino
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
* EEPROM Write
*
* Stores values read from analog input 0 into the EEPROM.
* These values will stay in the EEPROM when the board is
* turned off and may be retrieved later by another sketch.
EEPROM Write

Stores values read from analog input 0 into the EEPROM.
These values will stay in the EEPROM when the board is
turned off and may be retrieved later by another sketch.

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

// Include the EEPROM library
#include <EEPROM.h>

/** the current address in the EEPROM (i.e. which byte we're going to write to next) **/
Expand Down
6 changes: 6 additions & 0 deletions libraries/RTC/examples/RTC_Alarm/RTC_Alarm.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* RTC_Alarm
*
* This example demonstrates how to use the alarm functionality of the RTC
* (Real Time Clock) on the Portenta C33 and UNO R4 Minima / WiFi.
*
Expand All @@ -9,12 +11,16 @@
*
* Note that the Portenta C33's LED is inverted and will be lit when
* the state is 0 (LOW).
*
* Find the full UNO R4 WiFi RTC documentation here:
* https://docs.arduino.cc/tutorials/uno-r4-wifi/rtc
*/

unsigned long previousMillis = 0;
const long interval = 1000;
bool ledState = false;

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

void setup() {
Expand Down
Loading