daily pastebin goal
74%
SHARE
TWEET

Untitled

a guest Nov 8th, 2018 96 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. #include "pitches.h"
  2. #include <IRremote.h>
  3.  
  4. class Flasher
  5. {
  6.   int ledPin;
  7.   long OnTime;
  8.   long OffTime;
  9.  
  10.   int ledState;
  11.   unsigned long previousMillis;
  12.  
  13.   public:
  14.   Flasher(int pin, long on, long off)
  15.   {
  16.     ledPin = pin;
  17.     pinMode(ledPin, OUTPUT);
  18.  
  19.     OnTime = on;
  20.     OffTime = off;
  21.  
  22.     ledState = LOW;
  23.     previousMillis = 0;
  24.  
  25. }
  26.  
  27. void Update()
  28. {
  29.   unsigned long currentMillis = millis();
  30.  
  31.   if((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
  32.   {
  33.     ledState = LOW;
  34.     previousMillis = currentMillis;
  35.     digitalWrite(ledPin, ledState);
  36.   }
  37.   else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
  38.   {
  39.     ledState = HIGH;
  40.     previousMillis = currentMillis;
  41.     digitalWrite(ledPin, ledState);
  42.     }
  43.   }
  44. };
  45.  
  46. class Speaker
  47. {
  48.   int speaker;
  49.   int melody[] = {
  50.    
  51.   };
  52.  
  53.   int noteDurations[] = {
  54.    
  55.   };
  56.  
  57. public:
  58. Speaker()
  59. {
  60.  
  61. }
  62.  
  63. void Update()
  64. {
  65.  
  66. }
  67. };
  68.  
  69. class IR
  70. {
  71. int RECV_PIN;
  72. IRrecv irrecv(RECV_PIN); //Errors out here
  73. decode_results results;
  74.  
  75.  
  76. public:
  77. IR()
  78. {
  79.   pinMode(RECV_PIN, INPUT);
  80.   irrecv.enableIRIn();
  81.   irrecv.blink13(true);
  82. }
  83.  
  84. void Update()
  85. {
  86.   if (irrecv.decode(&results)){
  87.         Serial.println(results.value, HEX);
  88.         irrecv.resume();
  89.     }
  90.   }
  91. };
  92.  
  93. Flasher led1(12, 100, 400);
  94. IR      IRled1(7);
  95. Speaker
  96. void setup() {
  97.   // put your setup code here, to run once:
  98.       Serial.begin(9600);
  99. }
  100.  
  101. void loop() {
  102.   // put your main code here, to run repeatedly:
  103.     led1.Update();
  104.     IRled1.Update();
  105. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top