Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // GLAVNI ARDUINO
- int a = Serial.read();
- display.setCursor(SCR_SPEED_X, SCR_SPEED_Y);
- display.setTextSize(1);
- display.print(a);
- // UPDATE THE TAHOMETER
- display.fillRect(SCR_BRAKE_X, SCR_BRAKE_Y, SCR_BRAKE_W, 64, WHITE);
- display.fillRect(SCR_BRAKE_X, SCR_BRAKE_Y, SCR_BRAKE_W, 64 - map(a, 0, 150, 0, 64), BLACK);
- refreshScreen = true;
- // SPOREDNI ARDUINO
- // PINS
- #define PIN_RPM_SENSOR 3 // INTERRUPT PIN! DO NOT CHANGE IT!!
- // GLOBAL VARIABLES
- volatile uint32_t revDuration = 60000;
- volatile uint32_t revTick = 0;
- void revolution()
- {
- revDuration = millis() - revTick;
- revTick = millis();
- }
- void setup()
- {
- Serial.begin(9600);
- pinMode(PIN_RPM_SENSOR, INPUT);
- attachInterrupt(digitalPinToInterrupt(PIN_RPM_SENSOR), revolution, RISING); // INTERRUPT PIN 3
- }
- void loop()
- {
- Serial.write(60000 / revDuration);
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment