Alex Glow
Published © GPL3+

Programming ATtiny85 Chips (DIP and SOIC) with Arduino Code!

How to program a through-hole OR surface-mount ATtiny85 chip as a low-cost, low-power Arduino.

IntermediateProtip1 hour3,484
Programming ATtiny85 Chips (DIP and SOIC) with Arduino Code!

Things used in this project

Story

Read more

Code

Final code for #Avnet100Years badge

Arduino
This is the code for the PCB I use in the video.
// Morse Code beeper on ATTiny85
// A mashup of:
// Jeremy Cook, https://www.arrow.com/en/research-and-events/articles/programming-attiny85-with-arduino
// and
// MorseCodeMachine example "Example01-HelloWorld"
// by Alex Glow for Avnet, celebrating 100 years that started with ham radio parts!

#include <MorseCodeMachine.h>

int ledPin = 1;
int beepPin = 2;
int ditLength = 35; // cycles of square wave in a dit (*3 = dah)

void setup()
{
  // Set up the LED and buzzer as 
  pinMode(ledPin, OUTPUT);
  pinMode(beepPin, OUTPUT);
    
  digitalWrite(ledPin, HIGH);
}

void loop()
{
    sendMorse("Avnet 100 Years", ledDelay, ledDot, ledDash);
}

//Create a delay function and give it to the sendMorse function so that the
//sendMorse function can space out the letters and the words properly.
//You can give this function any name you want.
void ledDelay()
{
    //Wait for a small amount of time.
    delay(200);
}

// Beep for a short "dit" (dot)
void ledDot()
{
  for (int i=0; i < ditLength; i++) {
    digitalWrite(beepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(beepPin, LOW);
    delayMicroseconds(500);
  }
}

// A dah (dash) is 3 times as long as a dit.
void ledDash()
{
  for (int i=0; i < (ditLength * 3); i++) {
    digitalWrite(beepPin, HIGH);
    delayMicroseconds(500);
    digitalWrite(beepPin, LOW);
    delayMicroseconds(500);
  }
}

Credits

Alex Glow

Alex Glow

145 projects • 1571 followers
The Hackster team's resident Hardware Nerd. I love robots, music, EEG, wearables, and languages. FIRST Robotics kid.

Comments