I have a code I am wanting to run on a standalone atmega328 to sense the speed of a shaft and, if it has stopped/slowed to a set rpm it will flash an LED and play a sound. It worked fine on the uno, but when I went to test it on the standalone atmega328, it starts up then freezes or starts then resets. I will attach my code and a link to the standalone kit I purchased. I am
#include <PCM.h>
#include <Wire.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const int hallSensorPin = 2; //Set sensor to pin 2
const int ledPin = 13; //Set LedSilence to pin 13
const int buttonSilencePin = 7; //Set Silence button to pin 7
const int buttonDecreaseThresholdPin = 4; //Set increase Threshold to pin 4
const int buttonIncreaseThresholdPin = 12; //Set decrease threshold to pin 12
int buttonstate4; //Declare integer
int buttonstate12; //Declare integer
int SilenceLED = 10; //Declare integer for SilencingLED indicator
int threshold = 50; //Declare integer
volatile unsigned long lastTime = 0;
volatile unsigned long lastPulseTime = 0;
volatile unsigned long lastSpeedCheckTime = 0;
volatile unsigned int pulseCount = 0;
volatile float rpm = 0;
bool soundEnabled = true;
bool buttonSilenceState = false;
bool silencePressed = false;
bool silenced = false;
bool lastButtonSilenceReleased = false;
bool unsilencePressed = false;
bool displaySilencedMessage = false;
bool lastButtonSilenceState = false;
bool silenceToggle = false; // To toggle between silencing and unsilencing
bool buttonDecreaseState = false;
bool lastButtonDecreaseState = false;
bool buttonIncreaseState = false;
bool lastButtonIncreaseState = false;
bool thresholdChanged = false;
unsigned long thresholdChangedTime = 0;
unsigned long silencedDisplayTime = 500;
unsigned long lastButtonPressTime = 0;
const unsigned long buttonPressWindow = 200;
unsigned long lastPlaybackTime = 0;
const unsigned long playbackDelay = 1500; // 1.5 seconds delay
unsigned long lastToggleTime = 0; // To keep track of when to switch back to RPM display
// 'Beet', 128x32px
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET -1
#define SCROLL_SPEED 1 // Adjust the scroll speed (1 for slow, increase for faster)
// Change this I2C address to match your OLED display's address (common addresses are 0x3C or 0x3D)
#define OLED_I2C_ADDRESS 0x3C
// Hex data for the Sugar Beet
const unsigned char epd_bitmap_Beet[] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf1, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xae, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaf, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xef, 0xe8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3f, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x37, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x65, 0xce, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x7f, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xbe, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x78, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x7f, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe7, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x27, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x17, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x8b, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x43, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x41, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xe5, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x72, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x9a, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x41, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x87, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
//Array for the warning sound
const unsigned char sample[] PROGMEM = {
129, 128, 127, 129, 129, 128, 128, 129, 128, 128, 127, 127, 126, 125, 127, 127, 126, 127, 126, 127, 128, 128, 127, 128, 128, 128, 128, 128, 128, 127, 127, 128, 128, 127, 127, 130, 130, 128, 129, 127, 126, 127, 125, 123, 125, 126, 128, 130, 128, 127, 127, 128, 128, 126, 127, 126, 126, 127, 127, 127, 128, 128, 128, 129, 129, 128, 128, 129, 131, 130, 128, 126, 124, 125, 125, 126, 127, 127, 127, 124, 124, 129, 129, 127, 131, 134, 130, 127, 129, 130, 128, 122, 119, 128, 133, 130, 129, 130, 131, 131, 128, 126, 126, 124, 123, 126, 127, 122, 121, 129, 134, 131, 127, 129, 133, 130, 130, 132, 128, 127, 130, 128, 125, 127, 131, 132, 129, 126, 125, 128, 125, 119, 126, 132, 124, 122, 127, 124, 120, 126, 130, 126, 125, 129, 127, 123, 128, 131, 130, 130, 129, 127, 127, 130, 129, 126, 128, 133, 133, 126, 122, 130, 137, 131, 123, 126, 134, 131, 128, 130, 124, 121, 126, 126, 119, 116, 128, 138, 127, 120, 130, 136, 129, 118, 123, 133, 130, 123, 125, 129, 129, 132, 133, 127, 126, 132, 131, 125, 125, 129, 130, 128, 126, 124, 124, 129, 127, 121, 126, 133, 131, 126, 128, 133, 129, 123, 125, 130, 129, 125, 130, 138, 131, 122, 127, 132, 126, 116, 120, 136, 134, 120, 123, 131, 130, 124, 122, 127, 130, 128, 128, 128, 130, 130, 130, 131, 129, 125, 124, 129, 135, 133, 128, 127, 131, 129, 120, 116, 125, 132, 125, 120, 126, 127, 125, 125, 126, 127, 127, 127, 126, 126, 131, 130, 127, 128, 129, 128, 128, 132, 132, 128, 130, 137, 137, 125, 122, 135, 136, 120, 116, 128, 129, 116, 116, 129, 127, 118, 125, 133, 128, 124, 130, 132, 122, 122, 133, 133, 123, 124, 135, 139, 131, 126, 132, 134, 131, 131, 130, 125, 126, 131, 127, 123, 123, 124, 124, 127, 131, 129, 125, 129, 132, 124, 118, 125, 132, 126, 118, 121, 130, 129, 125, 128, 130, 126, 128, 130, 125, 121, 129, 135, 127, 120, 128, 135, 125, 119, 130, 135, 126, 122, 132, 136, 129, 121, 126, 133, 130, 126, 127, 125, 127, 134, 130, 123, 127, 130, 132, 130, 123, 124, 133, 131, 128, 127, 124, 123, 123, 121, 122, 124, 125, 126, 128, 130, 134, 134, 130, 130, 132, 131, 126, 126, 134, 133, 128, 133, 133, 128, 128, 127, 124, 126, 123, 119, 122, 125, 123, 120, 118, 121, 128, 128, 126, 128, 132, 133, 135, 134, 129, 126, 124, 127, 133, 130, 126, 129, 134, 128, 116, 119, 133, 134, 120, 119, 130, 132, 126, 123, 126, 131, 131, 127, 126, 130, 135, 136, 134, 131, 129, 132, 130, 122, 122, 128, 129, 124, 124, 126, 126, 125, 127, 127, 125, 126, 127, 127, 126, 127, 131, 133, 128, 127, 129, 129, 128, 125, 125, 127, 127, 126, 125, 119, 118, 128, 132, 125, 122, 128, 133, 129, 122, 123, 127, 131, 132, 128, 127, 131, 130, 125, 126, 128, 126, 124, 124, 124, 128, 133, 131, 132, 134, 132, 130, 130, 132, 130, 127, 132, 133, 130, 131, 129, 127, 127, 123, 123, 126, 124, 121, 123, 124, 120, 120, 121, 118, 122, 128, 128, 131, 135, 134, 135, 138, 135, 128, 125, 129, 135, 130, 130, 138, 136, 128, 123, 121, 126, 126, 120, 123, 128, 125, 119, 120, 124, 125, 125, 125, 128, 132, 133, 130, 131, 140, 139, 129, 123, 126, 131, 130, 127, 132, 133, 123, 118, 120, 121, 123, 126, 124, 124, 126, 125, 126, 127, 127, 126, 125, 128, 130, 129, 128, 130, 134, 134, 131, 127, 125, 128, 129, 128, 128, 127, 127, 130, 131, 128, 128, 130, 129, 124, 123, 128, 123, 119, 124, 126, 121, 120, 127, 127, 118, 119, 127, 128, 126, 132, 135, 130, 132, 138, 136, 128, 130, 140, 140, 127, 124, 135, 137, 125, 121, 124, 121, 116, 115, 120, 122, 118, 121, 127, 126, 124, 130, 137, 131, 124, 129, 140, 140, 127, 127, 142, 141, 124, 119, 134, 139, 127, 121, 127, 129, 124, 122, 126, 129, 123, 117, 124, 131, 125, 119, 127, 135, 127, 117, 123, 139, 136, 120, 124, 143, 141, 121, 119, 134, 133, 121, 123, 133, 132, 122, 123, 129, 127, 124, 125, 128, 126, 125, 124, 125, 130, 134, 129, 124, 127, 133, 130, 126, 128, 131, 128, 126, 129, 130, 127, 125, 128, 130, 127, 122, 122, 126, 131, 131, 129, 127, 124, 125, 127, 123, 120, 124, 126, 128, 128, 124, 125, 131, 132, 128, 125, 130, 134, 136, 136, 132, 129, 132, 133, 128, 128, 129, 126, 122, 123, 126, 120, 114, 119, 127, 126, 118, 117, 127, 129, 125, 126, 128, 130, 133, 134, 134, 133, 132, 132, 134, 134, 132, 135, 133, 124, 124, 130, 130, 124, 122, 125, 125, 122, 128, 133, 127, 122, 126, 131, 128, 128, 131, 129, 126, 130, 136, 132, 125, 126, 131, 129, 121, 119, 122, 122, 122, 123, 122, 122, 125, 127, 128, 127, 127, 132, 134, 128, 125, 126, 126, 130, 130, 122, 119, 127, 135, 131, 128, 131, 132, 130, 127, 126, 130, 134, 136, 131, 125, 128, 131, 126, 122, 127, 133, 128, 120, 122, 128, 121, 110, 114, 125, 124, 116, 121, 132, 130, 125, 130, 132, 128, 130, 136, 140, 137, 135, 140, 142, 134, 132, 139, 135, 125, 126, 128, 124, 122, 116, 116, 121, 116, 118, 125, 123, 124, 131, 131, 128, 128, 128, 131, 133, 129, 128, 129, 132, 132, 123, 120, 126, 125, 121, 121, 121, 124, 124, 125, 127, 130, 132, 131, 133, 136, 132, 130, 136, 133, 127, 127, 125, 130, 134, 125, 123, 125, 122, 125, 128, 125, 124, 129, 132, 127, 126, 125, 125, 128, 128, 129, 133, 129, 128, 130, 127, 126, 125, 122, 126, 125, 116, 124, 132, 125, 127, 132, 129, 126, 123, 128, 132, 129, 129, 135, 134, 129, 134, 135, 123, 124, 133, 127, 121, 125, 121, 117, 121, 126, 128, 125, 119, 127, 137, 132, 126, 128, 128, 129, 129, 128, 133, 133, 129, 132, 132, 128, 126, 126, 129, 132, 130, 121, 122, 130, 126, 123, 126, 124, 124, 124, 128, 132, 128, 129, 134, 132, 128, 126, 129, 131, 126, 125, 127, 126, 126, 125, 126, 127, 126, 125, 128, 129, 127, 125, 128, 133, 127, 120, 125, 129, 128, 129, 129, 132, 136, 133, 126, 127, 130, 125, 120, 124, 122, 120, 126, 131, 133, 129, 123, 134, 141, 125, 119, 125, 126, 127, 125, 120, 123, 130, 130, 126, 124, 124, 129, 130, 129, 132, 133, 129, 128, 130, 128, 126, 127, 128, 132, 135, 130, 132, 133, 126, 126, 127, 124, 124, 124, 124, 126, 126, 126, 127, 126, 123, 124, 128, 128, 127, 127, 127, 129, 129, 127, 124, 120, 129, 139, 135, 130, 129, 133, 136, 128, 122, 123, 129, 130, 125, 121, 119, 122, 129, 131, 124, 120, 124, 129, 130, 127, 122, 124, 128, 126, 128, 130, 128, 134, 137, 129, 127, 129, 130, 130, 129, 127, 123, 122, 128, 131, 122, 117, 125, 129, 126, 122, 124, 138, 141, 127, 125, 131, 132, 130, 126, 127, 133, 133, 130, 132, 128, 125, 128, 127, 124, 129, 136, 130, 123, 131, 135, 125, 116, 121, 125, 121, 118, 121, 128, 132, 128, 125, 125, 124, 125, 126, 124, 124, 125, 124, 127, 133, 134, 128, 128, 133, 133, 132, 133, 128, 125, 128, 129, 126, 124, 128, 131, 128, 121, 118, 121, 124, 126, 125, 126, 128, 132, 133, 130, 130, 132, 132, 129, 127, 128, 134, 141, 134, 122, 128, 136, 128, 114, 115, 127, 131, 126, 123, 125, 129, 126, 120, 120, 120, 124, 131, 131, 127, 133, 132, 123, 126, 133, 130, 128, 128, 133, 135, 129, 125, 127, 129, 131, 127, 126, 127, 118, 124, 144, 136, 118, 120, 129, 131, 125, 127, 128, 126, 137, 140, 122, 115, 127, 132, 127, 125, 127, 127, 126, 127, 126, 138, 155, 129, 73, 73, 135, 167, 140, 116, 130, 145, 125, 115, 151, 169, 149, 137, 129, 121, 118, 119, 115, 94, 98, 128, 120, 92, 112, 167, 171, 119, 137, 209, 179, 114, 138, 162, 123, 92, 109, 119, 77, 65, 116, 106, 49, 83, 150, 131, 97, 145, 191, 152, 133, 192, 202, 140, 137, 175, 144, 86, 101, 131, 96, 70, 108, 115, 69, 76, 128, 116, 77, 127, 193, 156, 115, 174, 223, 170, 129, 167, 173, 109, 88, 125, 113, 74, 92, 110, 78, 72, 117, 126, 83, 93, 167, 181, 129, 137, 200, 197, 140, 141, 170, 139, 94, 110, 129, 94, 84, 123, 115, 74, 96, 144, 123, 76, 115, 186, 169, 124, 159, 207, 177, 134, 154, 166, 117, 89, 118, 118, 83, 88, 106, 87, 74, 104, 124, 95, 91, 152, 184, 150, 142, 192, 205, 152, 135, 166, 151, 102, 105, 126, 104, 85, 98, 99, 78, 84, 123, 120, 85, 118, 181, 169, 133, 163, 207, 173, 129, 153, 165, 115, 93, 124, 117, 80, 90, 111, 90, 71, 103, 136, 106, 90, 151, 186, 148, 136, 187, 201, 148, 133, 167, 144, 91, 106, 137, 104, 75, 107, 120, 81, 71, 115, 126, 88, 109, 179, 176, 129, 154, 211, 186, 129, 152, 178, 125, 87, 122, 130, 91, 92, 115, 96, 72, 98, 129, 103, 87, 147, 183, 140, 126, 185, 207, 150, 128, 169, 159, 105, 109, 129, 97, 76, 102, 100, 62, 70, 124, 124, 80, 106, 175, 169, 125, 155, 212, 187, 138, 154, 172, 135, 107, 124, 121, 89, 95, 118, 93, 71, 106, 136, 103, 83, 139, 179, 143, 121, 175, 209, 158, 128, 163, 160, 109, 105, 129, 108, 82, 103, 114, 79, 70, 116, 132, 88, 91, 161, 179, 128, 134, 205, 201, 135, 140, 176, 140, 101, 119, 124, 96, 96, 115, 96, 69, 98, 136, 104, 72, 125, 177, 142, 112, 172, 210, 151, 125, 173, 160, 101, 110, 144, 120, 93, 112, 117, 77, 70, 124, 134, 83, 90, 159, 173, 124, 130, 196, 189, 130, 139, 167, 125, 94, 126, 132, 102, 105, 123, 99, 70, 101, 143, 113, 81, 130, 182, 151, 112, 160, 212, 163, 122, 159, 158, 106, 102, 135, 125, 93, 99, 110, 87, 81, 117, 131, 97, 99, 157, 179, 137, 125, 184, 194, 136, 133, 164, 131, 96, 119, 126, 96, 90, 109, 101, 78, 95, 134, 118, 87, 127, 183, 170, 130, 158, 203, 165, 121, 149, 153, 104, 97, 127, 118, 91, 94, 108, 98, 92, 122, 133, 101, 104, 161, 183, 147, 138, 189, 192, 130, 131, 161, 121, 86, 115, 131, 98, 82, 104, 107, 82, 53, 65, 167, 217, 115, 53, 153, 249, 219, 186, 186, 122, 74, 87, 72, 62, 93, 125, 123, 105, 126, 148, 139, 167, 182, 123, 94, 114, 94, 71, 124, 191, 177, 154, 172, 143, 71, 58, 104, 127, 98, 109, 182, 204, 195, 202, 157, 100, 73, 59, 68, 75, 103, 168, 194, 182, 168, 163, 152, 104, 70, 62, 55, 81, 124, 151, 175, 191, 192, 174, 131, 89, 65, 60, 82, 111, 139, 174, 194, 199, 192, 147, 100, 76, 46, 36, 77, 129, 168, 196, 206, 196, 154, 106, 78, 43, 24, 54, 110, 164, 192, 206, 216, 191, 137, 89, 59, 41, 43, 81, 137, 178, 205, 210, 184, 148, 115, 81, 53, 44, 67, 116, 156, 185, 208, 204, 171, 127, 88, 68, 49, 50, 87, 134, 179, 207, 202, 184, 155, 113, 81, 65, 55, 70, 113, 157, 185, 198, 199, 174, 130, 100, 78, 53, 54, 95, 149, 174, 181, 188, 177, 145, 107, 84, 66, 50, 70, 118, 166, 201, 203, 189, 166, 125, 96, 77, 50, 59, 104, 147, 175, 184, 192, 180, 136, 106, 86, 55, 37, 64, 119, 155, 174, 189, 193, 173, 129, 103, 77, 53, 77, 122, 154, 172, 182, 180, 159, 133, 104, 81, 77, 78, 92, 126, 158, 169, 172, 173, 152, 115, 91, 70, 67, 105, 142, 159, 174, 179, 175, 149, 110, 99, 84, 55, 67, 115, 163, 177, 178, 178, 140, 85, 60, 135, 211, 98, 8, 126, 249, 223, 83, 2, 50, 122, 196, 242, 227, 156, 48, 3, 30, 123, 248, 255, 181, 90, 4, 12, 74, 165, 249, 241, 173, 85, 4, 1, 111, 224, 254, 236, 144, 31, 1, 28, 140, 254, 246, 176, 82, 12, 6, 77, 184, 249, 252, 149, 42, 2, 8, 139, 246, 248, 224, 115, 7, 3, 42, 160, 250, 244, 200, 88, 10, 6, 80, 188, 246, 255, 153, 27, 5, 4, 127, 247, 255, 233, 111, 9, 2, 42, 166, 254, 254, 202, 78, 11, 10, 86, 210, 246, 252, 146, 0, 0, 25, 138, 244, 255, 217, 101, 0, 0, 69, 188, 247, 255, 174, 59, 0, 18, 136, 248, 245, 214, 135, 0, 1, 75, 186, 245, 255, 175, 61, 0, 9, 104, 231, 255, 255, 151, 2, 0, 13, 143, 238, 249, 202, 104, 0, 19, 86, 185, 252, 253, 165, 45, 5, 20, 99, 215, 250, 255, 167, 18, 0, 18, 142, 221, 245, 187, 8, 33, 240, 183, 14, 121, 239, 129, 0, 65, 255, 142, 39, 208, 243, 71, 0, 179, 233, 35, 32, 244, 231, 8, 22, 255, 220, 4, 79, 245, 137, 6, 103, 255, 128, 0, 177, 242, 48, 6, 234, 254, 16, 3, 239, 238, 11, 24, 255, 240, 11, 41, 236, 151, 0, 114, 255, 135, 0, 153, 255, 68, 6, 228, 253, 20, 0, 232, 240, 12, 27, 251, 232, 18, 46, 232, 211, 19, 54, 252, 132, 13, 81, 237, 238, 91, 128, 161, 2, 15, 195, 241, 151, 199, 193, 10, 8, 77, 239, 234, 187, 200, 90, 8, 3, 110, 245, 240, 203, 111, 57, 14, 13, 146, 240, 255, 183, 99, 16, 12, 79, 231, 248, 246, 170, 42, 7, 0, 101, 238, 252, 242, 141, 0, 6, 26, 146, 236, 255, 202, 126, 2, 3, 87, 215, 228, 236, 185, 49, 0, 2, 141, 254, 248, 195, 127, 22, 0, 9, 194, 255, 255, 162, 82, 7, 6, 106, 238, 245, 226, 148, 29, 0, 0, 168, 255, 255, 184, 108, 12, 4, 45, 200, 252, 252, 176, 99, 10, 8, 117, 245, 255, 210, 138, 17, 0, 5, 171, 255, 255, 168, 91, 9, 8, 74, 247, 255, 226, 149, 41, 5, 16, 165, 255, 255, 198, 122, 0, 0, 34, 185, 255, 255, 170, 90, 15, 0, 105, 246, 249, 207, 147, 19, 6, 23, 171, 248, 252, 205, 109, 0, 12, 128, 239, 191, 68, 174, 191, 23, 23, 201, 244, 95, 26, 46, 110, 120, 161, 241, 140, 60, 73, 106, 131, 147, 198, 191, 70, 0, 102, 180, 197, 219, 228, 129, 8, 9, 45, 143, 203, 255, 228, 111, 6, 60, 157, 194, 174, 137, 93, 6, 10, 122, 240, 255, 255, 169, 70, 22, 18, 41, 142, 226, 236, 197, 136, 81, 80, 121, 163, 143, 85, 77, 74, 84, 134, 197, 231, 230, 166, 91, 40, 25, 47, 92, 145, 184, 206, 205, 155, 120, 113, 91, 75, 63, 73, 104, 137, 180, 202, 187, 176, 154, 107, 64, 17, 32, 85, 153, 215, 235, 217, 164, 121, 85, 59, 75, 80, 81, 133, 164, 168, 179, 193, 189, 155, 98, 60, 29, 23, 75, 155, 205, 220, 216, 179, 124, 86, 69, 73, 75, 75, 123, 159, 173, 187, 190, 194, 164, 102, 52, 27, 40, 83, 133, 195, 225, 205, 164, 124, 106, 96, 85, 59, 65, 122, 139, 156, 200, 203, 178, 126, 89, 69, 42, 36, 98, 168, 193, 193, 192, 168, 136, 110, 85, 75, 62, 69, 116, 165, 193, 201, 182, 163, 144, 110, 59, 25, 44, 106, 152, 173, 181, 199, 193, 138, 94, 76, 57, 43, 86, 150, 179, 192, 190, 169, 152, 131, 99, 58, 31, 52, 101, 157, 196, 211, 205, 170, 137, 101, 59, 41, 55, 95, 139, 162, 202, 229, 198, 160, 127, 93, 118, 146, 56, 4, 82, 138, 142, 163, 200, 210, 154, 108, 95, 82, 95, 113, 118, 133, 126, 107, 123, 100, 57, 76, 87, 91, 130, 168, 185, 169, 182, 224, 204, 147, 142, 156, 127, 84, 80, 88, 66, 74, 127, 134, 88, 103, 143, 103, 69, 124, 165, 156, 163, 195, 194, 180, 173, 142, 113, 107, 110, 91, 81, 97, 119, 121, 98, 109, 133, 85, 48, 111, 171, 145, 143, 216, 235, 175, 153, 173, 147, 100, 91, 96, 75, 64, 85, 106, 110, 115, 146, 143, 93, 101, 153, 146, 115, 155, 208, 184, 144, 157, 171, 129, 95, 97, 90, 73, 78, 98, 104, 96, 112, 148, 125, 94, 143, 177, 134, 122, 184, 203, 147, 143, 185, 155, 100, 107, 119, 89, 71, 101, 122, 95, 87, 130, 143, 92, 90, 167, 176, 115, 131, 191, 170, 129, 159, 179, 134, 103, 123, 117, 82, 89, 115, 106, 86, 103, 138, 120, 89, 126, 176, 152, 126, 177, 203, 153, 135, 175, 156, 103, 108, 127, 101, 84, 97, 98, 78, 81, 118, 122, 84, 100, 163, 171, 127, 146, 211, 187, 136, 160, 176, 128, 98, 121, 125, 96, 94, 104, 90, 75, 101, 126, 105, 89, 139, 179, 142, 122, 176, 202, 142, 124, 171, 158, 101, 106, 136, 111, 85, 102, 110, 84, 83, 120, 123, 91, 107, 168, 170, 126, 148, 204, 184, 126, 141, 172, 129, 95, 123, 130, 97, 95, 110, 89, 71, 105, 133, 107, 91, 140, 182, 149, 123, 176, 210, 156, 121, 165, 164, 108, 105, 131, 113, 88, 105, 108, 75, 76, 125, 129, 82, 96, 171, 177, 122, 140, 206, 189, 131, 142, 167, 134, 106, 124, 125, 97, 100, 113, 85, 71, 113, 143, 104, 85, 143, 180, 146, 126, 174, 197, 141, 114, 157, 152, 96, 98, 131, 113, 88, 111, 116, 82, 88, 136, 133, 88, 104, 170, 178, 138, 144, 191, 185, 128, 130, 164, 129, 94, 118, 123, 92, 92, 110, 92, 72, 103, 138, 112, 82, 133, 189, 166, 131, 170, 210, 161, 116, 154, 160, 106, 104, 131, 111, 82, 98, 108, 81, 79, 123, 134, 95, 100, 163, 178, 135, 137, 191, 187, 131, 135, 171, 139, 96, 116, 129, 101, 90, 106, 98, 79, 100, 135, 117, 90, 128, 174, 152, 121, 163, 205, 159, 119, 157, 159, 100, 96, 133, 116, 84, 97, 110, 84, 77, 120, 136, 94, 94, 161, 181, 135, 139, 201, 197, 134, 137, 177, 143, 94, 117, 136, 103, 90, 112, 104, 75, 91, 126, 106, 78, 120, 171, 143, 112, 161, 206, 162, 121, 161, 175, 121, 109, 135, 120, 95, 100, 108, 89, 80, 115, 113, 73, 102, 172, 172, 121, 140, 221, 210, 126, 135, 177, 140, 99, 112, 120, 101, 96, 111, 100, 78, 98, 126, 100, 80, 135, 183, 147, 117, 175, 222, 164, 123, 167, 164, 104, 97, 123, 109, 89, 105, 112, 80, 79, 129, 127, 75, 102, 179, 174, 119, 136, 208, 197, 126, 141, 176, 131, 93, 119, 125, 90, 97, 121, 93, 67, 107, 143, 94, 66, 140, 189, 139, 110, 173, 214, 157, 124, 168, 163, 107, 111, 137, 112, 91, 115, 120, 84, 78, 124, 129, 82, 95, 174, 184, 121, 131, 206, 197, 126, 129, 170, 138, 96, 114, 120, 96, 96, 107, 90, 74, 99, 127, 104, 83, 136, 188, 154, 124, 175, 209, 155, 125, 164, 158, 103, 98, 126, 111, 82, 93, 108, 84, 76, 113, 131, 90, 90, 170, 188, 125, 131, 209, 202, 125, 133, 178, 135, 91, 118, 125, 92, 92, 117, 101, 72, 101, 143, 109, 68, 128, 190, 153, 112, 174, 218, 152, 121, 173, 166, 105, 105, 135, 113, 83, 102, 112, 82, 77, 123, 133, 86, 100, 174, 181, 128, 143, 212, 192, 122, 143, 183, 133, 86, 116, 133, 93, 79, 105, 99, 70, 89, 133, 103, 67, 130, 190, 148, 112, 179, 225, 158, 117, 176, 183, 111, 96, 135, 123, 82, 94, 118, 87, 67, 114, 130, 78, 84, 164, 180, 122, 129, 206, 202, 129, 136, 186, 152, 90, 107, 137, 107, 85, 110, 115, 85, 97, 137, 119, 83, 120, 174, 155, 117, 155, 210, 169, 113, 151, 176, 117, 92, 125, 122, 90, 94, 113, 91, 79, 114, 130, 89, 87, 159, 181, 131, 129, 195, 204, 137, 126, 174, 148, 97, 113, 130, 104, 90, 107, 105, 79, 89, 124, 110, 78, 115, 175, 160, 118, 155, 211, 170, 119, 151, 167, 114, 98, 135, 128, 93, 96, 119, 101, 79, 112, 136, 99, 88, 146, 175, 134, 124, 186, 199, 129, 116, 168, 145, 95, 116, 143, 114, 91, 111, 119, 85, 90, 138, 130, 86, 112, 175, 165, 118, 148, 202, 169, 114, 140, 167, 114, 87, 128, 135, 90, 91, 124, 107, 75, 103, 145, 115, 83, 138, 183, 147, 121, 175, 209, 150, 120, 163, 155, 93, 98, 135, 112, 81, 106, 117, 82, 83, 128, 129, 91, 110, 174, 171, 128, 144, 198, 186, 126, 132, 169, 130, 92, 124, 126, 88, 90, 113, 95, 75, 109, 138, 105, 90, 144, 181, 147, 130, 178, 201, 142, 120, 164, 159, 111, 101, 126, 113, 82, 94, 113, 103, 96, 112, 123, 95, 115, 178, 165, 118, 142, 181, 158, 127, 145, 155, 124, 110, 125, 121, 101, 98, 112, 85, 64, 108, 139, 160, 157, 63, 18, 157, 243, 224, 233, 221, 144, 63, 42, 74, 112, 115, 95, 103, 125, 132, 145, 167, 177, 123, 85, 89, 90, 105, 125, 168, 196, 166, 140, 145, 142, 87, 56, 99, 126, 103, 108, 178, 212, 195, 190, 175, 135, 88, 52, 45, 61, 96, 140, 170, 172, 161, 157, 139, 109, 85, 67, 64, 93, 142, 175, 189, 199, 183, 137, 99, 71, 58, 67, 82, 112, 155, 190, 201, 189, 162, 121, 85, 66, 48, 57, 107, 152, 183, 206, 209, 182, 138, 100, 68, 46, 42, 76, 138, 175, 193, 205, 195, 162, 115, 79, 60, 45, 54, 100, 151, 186, 205, 212, 194, 157, 107, 68, 46, 41, 74, 119, 161, 188, 195, 190, 160, 117, 86, 70, 54, 56, 102, 155, 184, 197, 200, 187, 154, 107, 68, 41, 41, 81, 133, 175, 197, 200, 184, 150, 107, 75, 58, 39, 53, 113, 167, 190, 203, 208, 190, 144, 100, 67, 39, 34, 72, 134, 183, 209, 206, 195, 154, 96, 75, 66, 46, 67, 120, 173, 200, 199, 192, 167, 121, 98, 73, 48, 59, 96, 140, 176, 195, 194, 178, 142, 100, 79, 61, 48, 78, 135, 184, 197, 189, 186, 163, 108, 80, 68, 68, 78, 106, 158, 186, 177, 188, 167, 117, 110, 98, 61, 48, 81, 140, 188, 188, 161, 166, 152, 95, 92, 92, 64, 75, 107, 151, 208, 192, 185, 158, 114, 98, 113, 112, 20, 11, 150, 248, 225, 125, 22, 5, 87, 193, 251, 254, 172, 59, 11, 17, 123, 246, 248, 210, 94, 6, 7, 70, 189, 254, 247, 112, 12, 8, 3, 113, 250, 254, 230, 103, 7, 7, 54, 175, 243, 249, 163, 83, 9, 16, 113, 212, 251, 230, 103, 11, 6, 27, 163, 250, 252, 179, 80, 4, 6, 81, 179, 245, 247, 150, 82, 7, 5, 147, 231, 250, 237, 105, 5, 5, 49, 170, 244, 251, 159, 81, 7, 11, 109, 212, 247, 247, 146, 37, 0, 7, 162, 251, 244, 213, 105, 3, 0, 79, 188, 246, 244, 152, 84, 10, 2, 94, 200, 245, 250, 177, 40, 0, 7, 131, 248, 248, 221, 115, 15, 3, 60, 186, 250, 245, 162, 59, 7, 5, 104, 245, 252, 234, 130, 5, 1, 43, 168, 247, 254, 204, 78, 6, 4, 76, 217, 248, 253, 160, 43, 4, 11, 130, 245, 246, 204, 129, 5, 5, 85, 171, 252, 253, 132, 0, 106, 253, 98, 0, 169, 249, 76, 3, 208, 252, 6, 3, 255, 249, 6, 28, 252, 248, 11, 11, 250, 190, 9, 116, 249, 114, 4, 147, 246, 76, 11, 207, 253, 41, 7, 227, 236, 8, 23, 250, 254, 7, 10, 253, 190, 1, 94, 255, 143, 0, 125, 248, 77, 10, 194, 250, 64, 9, 227, 245, 4, 2, 246, 251, 7, 5, 252, 227, 7, 67, 250, 155, 1, 108, 245, 98, 9, 177, 255, 85, 6, 121, 255, 203, 48, 184, 198, 2, 6, 206, 255, 138, 231, 218, 12, 0, 84, 234, 255, 178, 152, 116, 11, 4, 78, 249, 249, 170, 125, 36, 3, 8, 157, 249, 253, 161, 84, 0, 7, 92, 218, 251, 223, 110, 44, 11, 20, 107, 243, 253, 157, 113, 1, 9, 73, 191, 253, 248, 154, 77, 4, 5, 123, 226, 255, 248, 97, 3, 6, 30, 159, 247, 251, 193, 103, 7, 2, 62, 185, 255, 252, 171, 45, 0, 10, 105, 234, 251, 255, 144, 3, 5, 52, 153, 244, 247, 192, 105, 4, 5, 78, 188, 251, 254, 180, 42, 0, 5, 110, 233, 253, 254, 158, 9, 4, 43, 149, 251, 251, 232, 112, 0, 2, 61, 222, 247, 250, 202, 18, 4, 4, 124, 250, 252, 234, 131, 4, 4, 52, 199, 251, 246, 204, 81, 5, 2, 98, 252, 255, 215, 164, 7, 10, 6, 175, 246, 254, 208, 96, 0, 5, 169, 251, 160, 78, 238, 169, 0, 54, 229, 202, 55, 49, 152, 124, 83, 189, 251, 108, 22, 105, 178, 125, 127, 209, 134, 3, 21, 152, 189, 230, 255, 201, 66, 0, 8, 96, 175, 227, 255, 220, 121, 39, 57, 124, 142, 123, 124, 96, 47, 59, 163, 221, 251, 227, 149, 73, 15, 3, 55, 149, 194, 199, 199, 150, 103, 93, 124, 143, 130, 83, 74, 83, 106, 145, 204, 232, 218, 144, 73, 43, 19, 34, 98, 181, 206, 211, 194, 165, 105, 85, 90, 83, 79, 95, 119, 140, 156, 187, 202, 199, 149, 93, 66, 26, 25, 79, 158, 205, 220, 208, 185, 129, 73, 63, 79, 84, 96, 134, 152, 156, 170, 183, 187, 146, 99, 58, 28, 40, 82, 143, 206, 235, 211, 167, 128, 93, 63, 43, 71, 110, 133, 152, 182, 190, 171, 168, 149, 110, 57, 34, 54, 101, 147, 192, 214, 186, 156, 133, 107, 79, 65, 65, 76, 116, 161, 189, 206, 204, 170, 126, 77, 45, 50, 76, 115, 153, 185, 187, 176, 160, 144, 117, 77, 48, 63, 109, 135, 158, 181, 190, 182, 159, 119, 75, 47, 46, 75, 115, 146, 183, 211, 194, 162, 142, 102, 63, 55, 76, 107, 132, 160, 190, 194, 174, 159, 133, 80, 34, 42, 83, 119, 152, 192, 201, 194, 171, 116, 87, 75, 50, 59, 106, 156, 181, 184, 182, 181, 146, 76, 75, 162, 175, 51, 6, 85, 140, 138, 175, 221, 212, 160, 118, 108, 92, 105, 137, 132, 112, 117, 122, 122, 115, 119, 110, 87, 100, 133, 144, 143, 149, 184, 233, 216, 140, 100, 89, 80, 86, 78, 71, 101, 139, 142, 111, 110, 133, 108, 81, 105, 146, 155, 138, 163, 223, 212, 149, 147, 156, 113, 87, 91, 84, 75, 91, 120, 115, 102, 127, 128, 81, 79, 139, 164, 145, 155, 205, 214, 158, 147, 177, 135, 86, 97, 94, 65, 68, 103, 104, 95, 133, 161, 114, 83, 136, 171, 135, 125, 175, 199, 161, 135, 168, 157, 104, 109, 128, 90, 70, 105, 116, 85, 95, 137, 130, 96, 108, 156, 162, 131, 147, 196, 180, 135, 151, 170, 127, 104, 135, 128, 72, 76, 119, 97, 60, 106, 153, 117, 92, 147, 186, 144, 118, 165, 196, 149, 125, 162, 159, 98, 92, 133, 112, 74, 108, 133, 92, 72, 119, 139, 95, 96, 166, 176, 129, 138, 190, 188, 140, 152, 184, 136, 95, 129, 132, 80, 76, 119, 104, 67, 89, 125, 109, 85, 125, 170, 155, 131, 172, 211, 176, 140, 166, 163, 113, 102, 123, 101, 69, 86, 111, 90, 79, 116, 118, 71, 86, 186, 208, 121, 107, 197, 214, 132, 113, 172, 166, 91, 78, 111, 101, 110, 149, 131, 104, 133, 155, 125, 114, 140, 141, 117, 116, 130, 136, 128, 126, 124, 122, 119, 110, 106, 127, 150, 142, 129, 141, 155, 138, 122, 130, 137, 118, 110, 126, 128, 115, 114, 126, 129, 124, 120, 124, 129, 131, 133, 126, 121, 135, 139, 121, 120, 132, 129, 119, 124, 130, 130, 126, 125, 128, 126, 130, 137, 130, 123, 131, 136, 128, 121, 129, 129, 123, 126, 130, 129, 124, 120, 122, 125, 131, 125, 122, 129, 131, 125, 127, 130, 133, 131, 130, 130, 127, 131, 127, 122, 130, 130, 117, 116, 129, 136, 123, 123, 137, 131, 114, 122, 139, 135, 122, 134, 143, 130, 123, 127, 125, 124, 130, 134, 128, 125, 135, 131, 131, 132, 128, 121, 121, 124, 120, 113, 124, 132, 126, 124, 127, 129, 126, 116, 120, 133, 129, 119, 125, 140, 138, 127, 127, 133, 127, 124, 130, 132, 131, 136, 139, 130, 126, 133, 128, 124, 131, 130, 120, 117, 129, 127, 115, 122, 142, 134, 119, 126, 131, 120, 119, 127, 124, 127, 135, 132, 121, 119, 123, 130, 128, 120, 125, 137, 141, 133, 125, 132, 135, 130, 128, 124, 123, 125, 127, 128, 130, 137, 141, 127, 121, 131, 133, 124, 120, 128, 128, 114, 124, 139, 125, 116, 128, 132, 123, 118, 124, 127, 118, 118, 130, 130, 118, 124, 135, 133, 127, 128, 132, 132, 130, 132, 129, 123, 134, 142, 129, 120, 126, 132, 127, 126, 125, 125, 132, 130, 122, 118, 122, 129, 133, 127, 127, 129, 128, 124, 124, 125, 123, 125, 134, 139, 135, 125, 124, 130, 132, 132, 122, 121, 136, 136, 121, 119, 131, 137, 127, 122, 129, 136, 127, 116, 124, 132, 127, 122, 127, 132, 123, 118, 124, 125, 129, 130, 127, 127, 127, 126, 125, 129, 129, 129, 128, 126, 128, 131, 123, 125, 132, 132, 136, 134, 127, 124, 132, 133, 128, 125, 128, 130, 132, 135, 127, 122, 131, 131, 120, 119, 120, 122, 128, 130, 125, 124, 128, 130, 120, 117, 127, 133, 122, 116, 131, 134, 122, 124, 135, 130, 122, 125, 132, 132, 133, 135, 127, 124, 132, 136, 129, 122, 126, 133, 130, 127, 123, 128, 137, 134, 122, 121, 132, 131, 118, 122, 131, 128, 120, 120, 123, 121, 124, 122, 123, 132, 132, 124, 127, 135, 136, 130, 129, 135, 130, 125, 132, 141, 133, 124, 129, 134, 131, 124, 125, 126, 123, 123, 126, 126, 126, 126, 126, 124, 125, 128, 130, 136, 130, 125, 128, 124, 121, 127, 129, 127, 127, 127, 126, 126, 130, 127, 122, 129, 134, 127, 124, 126, 132, 134, 125, 123, 135, 139, 130, 124, 127, 132, 130, 130, 128, 124, 130, 134, 123, 118, 128, 129, 128, 127, 127, 133, 130, 124, 121, 119, 120, 123, 123, 120, 120, 124, 123, 123, 123, 126, 127, 128, 131, 127, 123, 135, 141, 132, 134, 134, 129, 131, 133, 134, 135, 134, 134, 131, 126, 128, 134, 131, 125, 124, 126, 126, 120, 119, 124, 125, 122, 122, 119, 121, 130, 128, 125, 129, 136, 135, 125, 123, 128, 130, 129, 127, 127, 130, 125, 121, 122, 124, 129, 131, 124, 124, 131, 128, 120, 118, 125, 131, 128, 126, 126, 127, 131, 133, 130, 129, 134, 137, 130, 127, 128, 127, 129, 130, 126, 124, 128, 130, 132, 134, 131, 127, 130, 131, 126, 122, 123, 129, 129, 124, 119, 116, 123, 135, 131, 120, 129, 135, 128, 125, 123, 126, 130, 126, 130, 134, 128, 132, 135, 128, 126, 131, 127, 122, 123, 126, 128, 128, 123, 120, 122, 126, 131, 131, 126, 129, 135, 131, 126, 124, 126, 129, 126, 123, 124, 127, 133, 131, 123, 120, 126, 131, 127, 120, 122, 131, 132, 122, 121, 130, 133, 128, 125, 127, 132, 135, 134, 132, 133, 131, 134, 133, 127, 126, 124, 121, 128, 130, 125, 127, 130, 130, 126, 124, 130, 134, 127, 121, 128, 135, 131, 125, 124, 128, 126, 123, 126, 126, 124, 127, 130, 129, 125, 123, 127, 129, 123, 121, 125, 127, 123, 122, 128, 131, 127, 126, 126, 124, 127, 130, 128, 129, 130, 127, 126, 126, 128, 128, 124, 127, 130, 128, 129, 139, 138, 128, 125, 132, 133, 120, 120, 133, 131, 123, 126, 132, 130, 122, 123, 133, 130, 119, 123, 135, 130, 121, 125, 131, 128, 123, 125, 133, 131, 129, 135, 134, 126, 125, 129, 129, 126, 124, 127, 127, 124, 126, 133, 129, 121, 128, 132, 125, 125, 130, 132, 127, 125, 128, 128, 125, 123, 124, 128, 132, 131, 126, 125, 130, 130, 121, 117, 124, 128, 127, 126, 128, 130, 127, 124, 127, 128, 124, 126, 131, 133, 135, 134, 130, 128, 132, 136, 130, 123, 130, 134, 125, 122, 133, 134, 124, 121, 129, 131, 122, 122, 128, 124, 119, 126, 131, 124, 123, 130, 130, 126, 122, 123, 128, 126, 122, 127, 130, 125, 122, 125, 128, 129, 129, 130, 127, 129, 134, 134, 131, 128, 132, 133, 127, 126, 126, 125, 132, 136, 128, 123, 128, 132, 125, 111, 116, 129, 128, 119, 121, 125, 131, 133, 126, 124, 128, 129, 130, 126, 124, 135, 136, 125, 128, 140, 134, 126, 134, 139, 126, 117, 132, 134, 117, 121, 138, 132, 118, 120, 131, 131, 119, 122, 132, 125, 120, 134, 135, 118, 119, 135, 134, 122, 122, 128, 133, 135, 129, 122, 125, 132, 131, 119, 115, 132, 139, 122, 116, 131, 138, 123, 115, 132, 135, 123, 128, 137, 133, 123, 125, 135, 129, 118, 127, 134, 126, 122, 127, 131, 123, 119, 125, 127, 123, 125, 131, 131, 128, 125, 125, 130, 133, 126, 122, 132, 141, 136, 124, 129, 139, 131, 119, 127, 138, 129, 118, 126, 135, 128, 120, 120, 126, 129, 127, 131, 132, 126, 125, 130, 127, 119, 124, 132, 126, 120, 126, 136, 129, 112, 118, 133, 132, 123, 125, 134, 134, 128, 127, 129, 128, 128, 129, 126, 126, 128, 128, 124, 121, 126, 124, 116, 121, 129, 126, 124, 127, 133, 130, 127, 130, 132, 137, 131, 123, 131, 132, 126, 126, 130, 131, 125, 130, 137, 126, 121, 131, 135, 126, 115, 123, 135, 129, 122, 131, 137, 127, 122, 126, 128, 132, 132, 125, 124, 130, 132, 127, 122, 127, 130, 123, 116, 127, 137, 125, 117, 128, 139, 123, 110, 130, 140, 124, 118, 130, 136, 126, 123, 134, 129, 121, 128, 135, 130, 123, 129, 135, 128, 125, 136, 137, 129, 128, 132, 131, 129, 130, 126, 125, 128, 128, 126, 125, 125, 123, 121, 121, 123, 123, 121, 121, 123, 124, 125, 127, 128, 129, 134, 135, 129, 129, 135, 139, 134, 126, 129, 133, 129, 127, 128, 122, 117, 123, 128, 126, 118, 118, 129, 130, 123, 124, 128, 130, 127, 126, 128, 127, 126, 132, 133, 126, 128, 135, 134, 125, 126, 136, 135, 125, 124, 130, 130, 126, 125, 126, 123, 123, 126, 126, 125, 124, 127, 132, 130, 126, 128, 131, 128, 124, 127, 131, 129, 127, 127, 128, 131, 130, 126, 126, 128, 134, 133, 120, 116, 129, 133, 124, 120, 123, 130, 131, 124, 126, 129, 130, 132, 130, 128, 126, 128, 137, 134, 126, 130, 135, 132, 123, 122, 131, 131, 123, 125, 130, 126, 123, 125, 126, 124, 123, 124, 122, 119, 119, 122, 122, 120, 122, 124, 127, 129, 130, 132, 140, 144, 137, 131, 135, 141, 136, 127, 129, 131, 126, 126, 128, 123, 118, 119, 124, 130, 124, 117, 123, 127, 122, 122, 126, 128, 125, 124, 127, 130, 127, 126, 129, 131, 130, 126, 128, 134, 133, 128, 128, 132, 133, 130, 128, 128, 129, 129, 127, 127, 126, 124, 126, 128, 126, 124, 128, 130, 128, 124, 125, 129, 128, 125, 124, 129, 130, 127, 127, 129, 129, 130, 131, 129, 128, 129, 132, 132, 124, 123, 130, 130, 125, 125, 126, 128, 128, 127, 128, 128, 128, 130, 129, 127, 127, 128, 131, 129, 126, 127, 127, 127, 127, 125, 124, 127, 129, 125, 125, 130, 130, 126, 126, 128, 128, 127, 127, 126, 125, 125, 124, 125, 125, 126, 126, 127, 129, 128, 128, 132, 134, 131, 128, 130, 134, 131, 126, 128, 129, 124, 122, 125, 127, 125, 123, 125, 126, 129, 129, 125, 127, 128, 127, 128, 129, 128, 127, 127, 129, 129, 127, 126, 128, 129, 129, 126, 127, 130, 129, 127, 128, 130, 129, 128, 128, 128, 128, 127, 125, 126, 127, 125, 124, 125, 126, 127, 128, 127, 128, 129, 129, 128, 128, 129, 128, 127, 129, 129, 128, 127, 127, 128, 128, 128, 127, 127, 128, 129, 129, 127, 126, 128, 129, 127, 126, 127, 128, 128, 125, 124, 126, 127, 127, 127, 127, 127, 127, 128, 130, 129, 127, 128, 130, 130, 127, 127, 128, 128, 128, 126, 127, 128, 128, 127, 127, 126, 127, 127, 128, 128, 126, 126, 126, 127, 129, 127, 127, 128, 127, 127, 127, 127, 128, 128, 128, 129, 129, 128, 128, 130, 129, 126, 126, 128, 128, 127, 127, 126, 126, 128, 129, 128, 127, 127, 127, 128, 128, 127, 127, 128, 127, 128, 128, 126, 128, 128, 127, 127, 126, 125, 126, 126, 127, 127, 126, 128, 129, 129, 128, 128, 130, 130, 128, 127, 129, 128, 127, 127, 127, 127, 127, 127, 128, 127, 127, 128, 128, 128, 128, 127, 127, 129, 128, 128, 127, 127, 128, 128, 126, 126, 126, 126, 126, 126, 127, 127, 127, 128, 128, 130, 129, 128, 129, 130, 128, 127, 128, 128, 127, 128, 128, 127, 127, 128, 128, 128, 128, 127, 127, 128, 128, 127, 127, 127, 128, 128, 128, 127, 126, 126, 126, 126, 127, 126, 127, 128, 128, 128, 128, 129, 128, 128, 128, 129, 128, 127, 128, 127, 127, 128, 128, 127, 127, 128, 128, 128, 127, 127, 128, 128, 127, 128, 128, 128, 128, 127, 128, 128, 126, 126, 127, 126, 126, 126, 127, 128, 128, 127, 128, 129, 129, 128, 128, 129, 128, 127, 128, 128, 127, 127, 128, 127, 128, 128, 127, 127, 129, 128, 127, 128, 128, 128, 127, 127, 128, 128, 127, 127, 127, 125, 125, 126, 127, 127, 126, 127, 128, 128, 128, 128, 129, 129, 129, 128, 128, 128, 128, 127, 127, 128, 127, 127, 127, 127, 127, 128, 128, 127, 128, 128, 127, 128, 127, 127, 128, 127, 128, 127, 126, 127, 126, 126, 126, 127, 127, 128, 128, 127, 128, 129, 129, 128, 128, 129, 128, 127, 128, 128, 127, 127, 128, 127, 127, 127, 127, 127, 128, 127, 127, 128, 127, 128, 128, 127, 128, 128, 127, 127, 126, 126, 125, 126, 127, 127, 127, 128, 128, 128, 128, 129, 129, 128, 129, 129, 128, 128, 128, 128, 127, 127, 127, 127, 127, 127, 127, 127, 128, 127, 128, 127, 127, 128, 127, 128, 128, 127, 128, 127, 126, 126, 126, 126, 126, 126, 127, 128, 128, 127, 128, 129, 129, 128, 128, 129, 128, 127, 128, 128, 127, 128, 127, 127, 127, 128, 127, 127, 128, 127, 127, 128, 127, 128, 128, 127, 128, 128, 127, 127, 126, 126, 126, 126, 127, 127, 127, 128, 128, 128, 128, 128, 128, 129, 128, 128, 128, 128, 128, 128, 127, 128, 127, 127, 127, 127, 127, 128, 128, 127, 128, 128, 127, 128, 127, 127, 128, 127, 128, 127, 126, 126, 126, 126, 126, 126, 127, 128, 128, 127, 128, 129, 129, 128, 128, 129, 128, 127, 128, 128, 127, 128, 128, 127, 127, 128, 127, 127, 128, 127, 127, 128, 127, 128, 127, 127, 128, 128, 127, 127, 126, 126, 126, 126, 127, 127, 127, 127, 128, 128, 128, 128, 128, 128, 129, 128, 128, 128, 128, 128, 128, 127, 127, 128, 127, 127, 127, 128, 128, 127, 128, 128, 127, 128, 127, 128, 128, 127, 127, 127, 126, 126, 126, 126, 127, 126, 127, 128, 128, 127, 128, 129, 129, 128, 128, 129, 128, 127, 128, 128, 127, 128, 128, 127, 127, 128, 127, 127, 128, 127, 127, 128, 127, 128, 128, 127, 128, 128, 127, 127, 126, 126, 126, 126, 127, 127, 127, 127, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 127, 128, 127, 127, 128, 127, 127, 128, 127, 128, 127, 126, 127, 126, 126, 127, 126, 127, 128, 128, 128, 128, 129, 129, 128, 128, 129, 128, 127, 128, 128, 127, 128, 128, 127, 127, 128, 127, 127, 128, 127, 127, 128, 127, 128, 128, 127, 128, 127, 127, 127, 126, 126, 126, 126, 127, 127, 127, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 127, 127, 127, 127, 127, 127, 127, 127, 128, };
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 528)
const int epd_bitmap_allArray_LEN = 1;
const unsigned char* epd_bitmap_allArray[1] = {
epd_bitmap_Beet
};
enum DisplayMode {
RPM, //Sets display modes to RPM and THRESHOLD options
THRESHOLD
};
DisplayMode currentDisplayMode = RPM; //Sets current display mode
unsigned long displayChangeTime = 0; //Sets time to change display
const unsigned long displayChangeDuration = 1000; //Sets time to change between displays
void hallSensorInterrupt() //Counts pulses of hall sensor
{
pulseCount++;
}
void setup()
{
pinMode(hallSensorPin, INPUT_PULLUP); //Setup pin as input
pinMode(ledPin, OUTPUT); //Setup pin as Output
pinMode(buttonSilencePin, INPUT_PULLUP); //Setup pin as input
pinMode(buttonDecreaseThresholdPin, INPUT_PULLUP); //Setup pin as input
pinMode(buttonIncreaseThresholdPin, INPUT_PULLUP); //Setup pin as input
pinMode(SilenceLED, OUTPUT); //Setup pin as Output
attachInterrupt(digitalPinToInterrupt(hallSensorPin), hallSensorInterrupt, FALLING);
Serial.begin(9600); //Allow for serial data debugging
if (!display.begin(0x3C)) //Initialize the display
{
Serial.println(F("SSD1306 allocation failed"));
for (;;)
;
}
display.display();
delay(2000); // Show the Beet image for 2 seconds
display.clearDisplay(); // Clear the display before scrolling
display.display(); // Display the cleared display
for (int16_t x = -SCREEN_WIDTH; x < SCREEN_WIDTH; x++) { // Start scrolling the image
display.clearDisplay();
display.drawBitmap(x, 0, epd_bitmap_Beet, 128, 32, SSD1306_WHITE);
display.display();
delay(SCROLL_SPEED);
}
display.stopscroll(); // Stop scrolling and clear the display
display.clearDisplay(); // Clear Display
display.display(); // Show cleared display
display.display();
display.setTextColor(SSD1306_WHITE); // Set text to white
display.setTextSize(3.5); // Increase text size 3.5X
display.setCursor(0, 0); // Reset Starting Point
display.println("WD 1222"); // Write out the words
display.display(); // Display the text
delay(2000); // Wait for 2 seconds
display.clearDisplay(); // Clear the display
delay(1000); // Wait for 1 second
currentDisplayMode = RPM; // Set display to RPM mode
displayChangeTime = millis();
}
void loop()
{
unsigned long currentTime = millis();
unsigned long timeElapsed = currentTime - lastSpeedCheckTime;
if (pulseCount >= 1) // Check if shaft has moved
{
rpm = (float)pulseCount * (60000.0 / (float)timeElapsed); // RPM Calculation
pulseCount = 0; // Reset pulsecount for next reading
lastSpeedCheckTime = currentTime; // Reset time between revolutions
lastPulseTime= currentTime; // Reset time between pulses
display.clearDisplay(); // Clear rpm value
display.setCursor(0, 0); // Reset Cursor
switch (currentDisplayMode) { // Changing of display modes
case RPM:
display.setTextSize(3.5); // Set text to 3.5x size
display.println(rpm); // Display rpm value
break;
case THRESHOLD:
display.setTextSize(2); // Set text to 2x size
display.println("Threshold: " + String(threshold)); // Display the changed threshold
break;
}
display.display();
}
if (currentTime - lastPulseTime >= 1500) // Test if no pulses within 1.5 seconds
{
rpm = 0; // Set RPM to 0
// Update the display with RPM 0
display.clearDisplay(); // Clear Display
display.setCursor(0, 0); // Reset Cursor
display.setTextSize(3.5); // Set text to 3.5x size
display.println(rpm); // Display rpm
display.display(); // Display previous
}
buttonSilenceState = digitalRead(buttonSilencePin); // Check state of silence button
if (buttonSilenceState != lastButtonSilenceState) // Check if silence button has been pressed
{
if (buttonSilenceState == LOW && (currentTime - lastButtonPressTime >= buttonPressWindow)) //Check if it has been pressed between now and previous
{
soundEnabled = !soundEnabled; // Toggle sound variable
silencePressed = !silencePressed; // Toggle button variable
lastButtonPressTime = currentTime; // Reset time
if (silencePressed) { // Check if it has been pressed
silenced = !silenced; // Change silence variable
silencedDisplayTime = currentTime; // Reset display time
lastToggleTime = currentTime; // Reset toggle timer
if (silenced) {
display.clearDisplay(); // Clear Display
display.setTextSize(2); // Set text to 2x size
display.setCursor(0, 0); // Reset cursor
display.println("Silenced"); // Display message on OLED
display.display(); // Send message to screen
digitalWrite(SilenceLED, HIGH);
delay(500); // Wait .5 seconds
displaySilencedMessage = true; // Change message indicating message was sent
} else {
displaySilencedMessage = false; // Indicate no message was sent
}
}
}
lastButtonSilenceState = buttonSilenceState; // Change Button state
}
if (displaySilencedMessage && (currentTime - silencedDisplayTime >= 2000)) { // Check if message has been sent and if it has been longer than 2 seconds
silenced = false; // Set silenced value to false
displaySilencedMessage = false; // Do not display silence message
lastToggleTime = currentTime; // Reset the toggle timer
}
if (silenced) {
digitalWrite(ledPin, LOW); // Turn Led off
} else {
if (currentTime - lastToggleTime >= 2000) { // Check if hall sensor has been activated in last 2 seconds
currentDisplayMode = RPM; // Set display to RPM function
}
if (rpm <= threshold && soundEnabled) { // Check if rpm is below threshold and sound is enabled
if (currentTime - lastPlaybackTime >= playbackDelay) { // Check if enough time has passed to play sound
digitalWrite(ledPin, HIGH); // Turn on Led
startPlayback(sample, sizeof(sample)); // Start Playing sound
lastPlaybackTime = currentTime; // Update the last playback time
digitalWrite(SilenceLED, LOW);
}
} else {
digitalWrite(ledPin, LOW); // Turn off Led
stopPlayback(); // Stop playing sound
}
}
buttonstate4 = digitalRead(buttonDecreaseThresholdPin); // Read decrease button value
if (buttonstate4 == LOW) // Check if button was pressed
{
threshold -= 5; // Subtract 5 from threshold
display.clearDisplay(); // Clear Display
display.setCursor(0, 0); // Reset Cursor
display.setTextSize(2); // Change text to 2x size
display.println("Threshold: " + String(threshold)); // Print Threshold and new value
display.display(); // Send the text to display
delay(250); // Wait .25 seconds
display.clearDisplay(); // Clear the Display
lastToggleTime = currentTime; // Reset the toggle timer
}
buttonstate12 = digitalRead(buttonIncreaseThresholdPin); // Read increase button value
if (buttonstate12 == LOW) // Check if button was pressed
{
threshold += 5; // Add 5 to threshold
display.clearDisplay(); // Clear the display
display.setCursor(0, 0); // Reset Cursor
display.setTextSize(2); // Set text size to 2x size
display.println("Threshold: " + String(threshold)); // Print Threshold and new value
display.display(); // Send the text to display
delay(250); // Wait .25 seconds
display.clearDisplay(); // Clear the display
lastToggleTime = currentTime; // Reset the toggle timer
}
}