Skip to content

Instantly share code, notes, and snippets.

Last active Apr 19, 2021
What would you like to do?
Use an ATTiny 85 to 'push' momentary button
#include <avr/sleep.h>
#define adc_disable() (ADCSRA &= ~(1<<ADEN)) // disable ADC (before power-off)
int buttonPin = 0; // phyisical pin 5
int ledPin = 4; // physical pin 3
void setup() {
// set pin to floating
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
// wait 2 seconds for electronics to fully power up
// Simulate button press & turn on led
pinMode(buttonPin, OUTPUT);
digitalWrite(buttonPin, LOW);
digitalWrite(ledPin, HIGH);
// Hold button press for 3 seconds
// Set pin to floating and turn off LED
pinMode(buttonPin, INPUT);
digitalWrite(ledPin, LOW);
// Go to sleep
void loop() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment