Commit 9a4348a5 by Risto Heinsar

added wk 5 demo codes

parent 9693399c
#define BUTTON_PIN 2
#define STATUS_LED_PIN 7
const uint8_t debounceDelay = 100;
volatile bool robotEnabled = true;
void setup()
{
/* Surunupp */
pinMode(BUTTON_PIN, INPUT);
/* Roboti seisundi LED */
pinMode(STATUS_LED_PIN, OUTPUT);
/* Konfigureerime katkestuse nupu langevale äärele */
attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), RobotPower, FALLING);
}
void loop()
{
digitalWrite(STATUS_LED_PIN, robotEnabled);
}
void RobotPower(void)
{
static uint32_t lastDebounceTime = 0;
/* stabiliseerimismehhanism, et nupu häiringuid vähendada */
if ((millis() - lastDebounceTime) > debounceDelay)
{
lastDebounceTime = millis();
robotEnabled = !robotEnabled;
}
}
\ No newline at end of file
/* IRRemote teek vajab dekodeerimise makrot enne teegi lisamist */
#define DECODE_SAMSUNG
#include <IRremote.hpp>
#define LEFT_LED_PIN 7
#define IR_RECEIVE_PIN 10
void setup()
{
Serial.begin(9600);
/* IR seadistamine koos seisundi LEDi määramisega */
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK, LEFT_LED_PIN);
}
void loop()
{
if (IrReceiver.decode())
{
/* Alustame järgmise paketi kuulamist enne töötlust (reageerib paremini) */
IrReceiver.resume();
/* Kontrollime kas samsungi IR pakett */
if (IrReceiver.decodedIRData.protocol == SAMSUNG)
{
/* Väljastame dekodeeritud paketi ja saadame üle jadaühenduse */
IrReceiver.printIRResultShort(&Serial);
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment