Skip to content

Instantly share code, notes, and snippets.

@gigafide
Last active February 15, 2020 02:25
Show Gist options
  • Save gigafide/300c43dd6a16a0259ce494405eb9feed to your computer and use it in GitHub Desktop.
Save gigafide/300c43dd6a16a0259ce494405eb9feed to your computer and use it in GitHub Desktop.
Arduino code for using a Star Wars Force Trainer headset as an TV remote control.
#include <IRremote.h>
#include <IRremoteInt.h>
#include <Brain.h>
IRsend irsend;
Brain brain(Serial);
const int ledPin = 3;
long interval = 500;
long previousMillis = 0;
int ledState = LOW;
int medValue;
void setup() {
// Set up the LED pin.
pinMode(ledPin, OUTPUT);
// Start the hardware serial.
Serial.begin(9600);
}
void loop() {
// Expect packets about once per second.
if (brain.update()) {
Serial.println(brain.readCSV());
// Attention runs from 0 to 100.
medValue = brain.readMeditation();
}
// Make sure we have a signal.
if(brain.readSignalQuality() == 0) {
// Send a signal to the LED.
if (medValue < 50) {
irsend.sendNEC(0x10EFA05F, 32); //ADD YOUR OWN IR REMOTE CODE HERE!
delay(40);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment