GY-63_MS5611/libraries/PulsePattern/examples/random_pattern/random_pattern.ino

54 lines
1.1 KiB
Arduino
Raw Normal View History

2020-11-27 05:28:57 -05:00
//
// FILE: random_pattern.ino
// AUTHOR: Rob Tillaart
// DATE: 2020-07-04
2021-12-24 09:10:06 -05:00
// PURPOSE: demo of the PulsePattern Library
2020-11-27 05:28:57 -05:00
// uses timer1
2021-12-24 09:10:06 -05:00
2020-11-27 05:28:57 -05:00
#include "PulsePattern.h"
2021-12-24 09:10:06 -05:00
2020-11-27 05:28:57 -05:00
// a pattern constants of durations of LOW and HIGH periods
// so the first line of the SOSpattern
// 500 units LOW, 500 units HIGH etc
// for a dutycycle of 50% LOW and HIGH should have equal periods
// NOTE max period = 4095.
// min period = about 12
uint16_t random_pattern[] = { 500, 500 };
uint8_t patternSize = 2;
uint8_t startLevel = LOW;
2021-12-24 09:10:06 -05:00
2020-11-27 05:28:57 -05:00
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
// as the prescaler = 1024 the periods of the pattern are a
// few percent less than a millisecond
PPGenerator.init(13, random_pattern, patternSize, startLevel, PRESCALE_1024);
PPGenerator.start();
}
2021-12-24 09:10:06 -05:00
2020-11-27 05:28:57 -05:00
void loop()
{
random_pattern[0] = 100 + millis() % 1000;
random_pattern[1] = 100 + micros() % 1000;
Serial.print(millis());
Serial.print('\t');
Serial.print(micros());
Serial.print('\t');
Serial.print(random_pattern[0]);
Serial.print('\t');
Serial.print(random_pattern[1]);
Serial.println();
delay(5000);
}
2021-12-24 09:10:06 -05:00
2020-11-27 05:28:57 -05:00
// -- END OF FILE --
2021-12-24 09:10:06 -05:00