Skip to content

Instantly share code, notes, and snippets.

@erm3nda
Created August 18, 2020 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erm3nda/e262d1f62c9fac678db066a813a19d5d to your computer and use it in GitHub Desktop.
Save erm3nda/e262d1f62c9fac678db066a813a19d5d to your computer and use it in GitHub Desktop.
Arduino blinking led example but fixed to work also on boards with less PIN, ie attiny85 #arduino #c
#include <Arduino.h>
// Attiny85 doesn't have nor recognize LED_BUILTIN 13 from Arduino.h
// Little fix to enable led blink with a LED on PIN 3 + GND to test boards.
#ifndef LED_BUILTIN
#define LED_BUILTIN 3
#endif
void setup() {
// initialize digital pin LED_BUILTIN as an output.
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
Serial.write(LED_BUILTIN + "\n");
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment