Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define adc_disable() (ADCSRA &= ~(1<<ADEN))
- const int wakeUpPin = PB0;
- const int powerCheckPin = PB1;
- // Generally, you should use "unsigned long" for variables that hold time
- // The value will quickly become too large for an int to store
- unsigned long previousMillis = 0; // will store last time PB0 went HIGH
- // constants won't change:
- const long interval = 30000; // interval to check if sound card is sleeping (milliseconds)
- void setup() {
- pinMode(wakeUpPin, OUTPUT);
- pinMode(powerCheckPin, INPUT);
- //Other pins as Input with the purpose of saving energy
- pinMode(PB2, INPUT);
- pinMode(PB3, INPUT);
- pinMode(PB4, INPUT);
- //ADC disabled - energy save
- adc_disable();
- }
- void loop() {
- while(digitalRead(powerCheckPin)){
- //do nothing while the card is ON (PB1 is HIGH)
- }
- // check to see if it's time to check for voltage in the powerCheckPin;
- unsigned long currentMillis = millis();
- if (currentMillis - previousMillis >= interval) {
- // save the last time voltage was checked
- previousMillis = currentMillis;
- // try to wakeup the Sound Card with a brief short circuit
- //Provide a 20K resistor to avoid damage the board and USB port
- digitalWrite(wakeUpPin, HIGH);
- delay(10);
- digitalWrite(wakeUpPin, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement