signals.ino 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //When the reflow starts, preheat leds will fast blink
  2. //to indicate auto reflow will start in 5 seconds
  3. void playStartingLEDBlinks(){
  4. digitalWrite(LED_PREHEAT, LOW);
  5. for(int i = 0; i < 10; i++){
  6. digitalWrite(LED_PREHEAT, HIGH);
  7. delay(200);
  8. digitalWrite(LED_PREHEAT, LOW);
  9. delay(200);
  10. }
  11. }
  12. //Update the button press state to global variable
  13. void updateButtonPressState(){
  14. int x = digitalRead(START_BTN);
  15. startPressed = (x == LOW);
  16. x = digitalRead(STOP_BTN);
  17. stopPressed = (x == LOW);
  18. }
  19. //Handle LED states in this cycle
  20. void handleLEDBlinking(){
  21. //FastBlink handler, execute every 500ms
  22. if (cycleCounter % 5 == 0 && fastblinkRed) {
  23. digitalWrite(LED_PREHEAT, LOW);
  24. if (fastBlinkState) {
  25. digitalWrite(LED_REFLOW, HIGH);
  26. } else {
  27. digitalWrite(LED_REFLOW, LOW);
  28. }
  29. fastBlinkState = !fastBlinkState;
  30. }
  31. //Blink handler, execute every 2 seconds
  32. if (cycleCounter % 20 == 0) {
  33. if (blinkYellow) {
  34. if (blinkState) {
  35. digitalWrite(LED_PREHEAT, HIGH);
  36. } else {
  37. digitalWrite(LED_PREHEAT, LOW);
  38. }
  39. } else if (blinkRed) {
  40. if (blinkState) {
  41. digitalWrite(LED_REFLOW, HIGH);
  42. } else {
  43. digitalWrite(LED_REFLOW, LOW);
  44. }
  45. }
  46. blinkState = !blinkState;
  47. }
  48. }