This commit is contained in:
2025-06-23 11:51:54 +02:00
commit 8108b800da
13 changed files with 1030 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
/*
This code will blink an LED attached to pin 13 on and off.
It will stay on for 0.25 seconds.
It will stay off for 1 second.
*/
#include <Metro.h> //Include Metro library
#define LED 13 // Define the led's pin
//Create a variable to hold theled's current state
int state = HIGH;
// Instanciate a metro object and set the interval to 250 milliseconds (0.25 seconds).
Metro ledMetro = Metro(250);
void setup()
{
pinMode(LED,OUTPUT);
digitalWrite(LED,state);
}
void loop()
{
if (ledMetro.check() == 1) { // check if the metro has passed its interval .
if (state==HIGH) state=LOW;
else state=HIGH;
digitalWrite(LED,state);
}
}

View File

@@ -0,0 +1,51 @@
// This code will blink output 13 every 250 ms
// abd will blink output 9 every 125 ms
#include <Metro.h> // Include Metro library
#define LED0 13 // Define a LED pin
#define LED1 9 // Define another LED pin
// Create variables to hold the LED states
int state0 = HIGH;
int state1 = HIGH;
// Instantiate a metro object and set the interval to 250 milliseconds (0.25 seconds).
Metro metro0 = Metro(250);
// Instantiate another metro object and set the interval to 125 milliseconds (0.125 seconds).
Metro metro1 = Metro(125);
void setup()
{
pinMode(LED0,OUTPUT);
digitalWrite(LED0,state0);
pinMode(LED1,OUTPUT);
digitalWrite(LED1,state1);
}
void loop()
{
if (metro0.check() == 1) { // check if the metro has passed its interval .
if (state0==HIGH) {
state0=LOW;
} else {
state0=HIGH;
}
digitalWrite(LED0,state0);
}
if (metro1.check() == 1) { // check if the metro has passed its interval .
if (state1==HIGH) {
state1=LOW;
} else {
state1=HIGH;
}
digitalWrite(LED1,state1);
}
}

View File

@@ -0,0 +1,36 @@
/*
This code will blink an LED attached to pin 13 on and off.
It will stay on for 0.25 seconds.
It will stay off for 1 second.
*/
#include <Metro.h> //Include Metro library
#define LED 13 // Define the led's pin
//Create a variable to hold theled's current state
int state = HIGH;
// Instanciate a metro object and set the interval to 250 milliseconds (0.25 seconds).
Metro ledMetro = Metro(250);
void setup()
{
pinMode(LED,OUTPUT);
digitalWrite(LED,state);
}
void loop()
{
if (ledMetro.check() == 1) { // check if the metro has passed its interval .
if (state==HIGH) {
state=LOW;
ledMetro.interval(250); // if the pin is HIGH, set the interval to 0.25 seconds.
}
else {
ledMetro.interval(1000); // if the pin is LOW, set the interval to 1 second.
state=HIGH;
}
digitalWrite(LED,state);
}
}

View File

@@ -0,0 +1,24 @@
// This example sends a Serial message every 250 milliseconds
#include <Metro.h> // Include the Metro library
Metro serialMetro = Metro(250); // Instantiate an instance
void setup() {
Serial.begin(115200); // Start the Serial communication
}
void loop() {
if (serialMetro.check() == 1) { // check if the metro has passed it's interval .
// Output all the analog readings seperated by a space character
for (int i = 0; i < 6; i++ ) {
Serial.print (analogRead( i) );
Serial.print(32,BYTE);
}
// Terminate message with a linefeed and a carriage return
Serial.print(13,BYTE);
Serial.print(10,BYTE);
}
}