Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Arduino Attiny85 algorithm to wake up USB soundcard device
#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
void loop() {
//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);
digitalWrite(wakeUpPin, LOW);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.