I have a very simple application that is failing to boot when power is applied to the USB port on the TeensyLC. If I have the loader open and press the program button it will reboot and load my application, however if I close the loader or use another PC as a power source then it will not boot.
This is a simple application that wakes up a screen when you walk by a motion sensor.
This is a simple application that wakes up a screen when you walk by a motion sensor.
Code:
const int MOTION_PIN = 0; // Pin connected to motion detector
const int LED_PIN = 13; // LED pin - active-high
unsigned long seconds = 1000L; // !!! SEE THE CAPITAL "L" USED!!!
unsigned long minutes = seconds * 60;
void setup()
{
// Serial.begin(9600);
// The PIR sensor's output signal is an open-collector,
// so a pull-up resistor is required:
pinMode(MOTION_PIN, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT);
}
void loop()
{
delay(1000);
// int proximity = digitalRead(MOTION_PIN);
// if (proximity == LOW) // If the sensor's output goes low, motion is detected
if (digitalRead(MOTION_PIN) == LOW)
{
Keyboard.press(KEY_SCROLL_LOCK); //press the scroll lock button
delay(25); //short delay
Keyboard.release(KEY_SCROLL_LOCK); //release the scroll lock button (scroll lock is now ON)
delay(25); //short delay
Keyboard.press(KEY_SCROLL_LOCK); //press the scroll lock button again
delay(25); //short delay
Keyboard.release(KEY_SCROLL_LOCK); //release the scroll lock button (scroll lock is now OFF again)
digitalWrite(LED_PIN, LOW);
delay(5 * minutes); //5 minute delay - don't need to do it again any time soon, monitor should already be on
}
else
{
digitalWrite(LED_PIN, HIGH);
}
}