Hamza Deniz YILMAZPCBWay
Published © CERN-OHL2

Making Macropad with Attiny85

Our board has an ATtiny85 microcontroller. This processor is a powerful 8-legged processor. The project that makes this microcontroller.

IntermediateWork in progress1 hour366
Making Macropad with Attiny85

Things used in this project

Hardware components

ATtiny85
Microchip ATtiny85
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Macropad_Schematik

Macropad_Schematik

Macropad_Borad

Macropad_Borad

Macropad_Gerber

Macropad_Gerber

Macropad_BOM

Macropad_BOM

Macropad_CPL

Macropad_CPL

MACRODEP_schematik

MACRODEP_schematik

Code

Code

C/C++
Code
int sensorValue = 0;

void setup() {
    //You need not set pin mode for analogRead - though if you have set the pin to
    //output and later want to read from it then you need to set pinMode(0,INPUT);
    //where 0 is the physical pin number not the analog input number.
    //
    //See below for the proper pinMode statement to go with each analog read.
}

void loop() {
    // The analog pins are referenced by their analog port number, not their pin
    //number and are as follows:

    sensorValue = analogRead(1); //Read P2
    //To set to input: pinMode(2, INPUT);
    //THIS IS P2, P2 is analog input 1, so when you are using analog read, you refer to it as 1.

    //sensorValue = analogRead(2); //Read P4
    //To set to input: pinMode(4, INPUT);
    //THIS IS P4, P4 is analog input 2, so when you are using analog read, you refer to it as 2.

    //sensorValue = analogRead(3); //Read P3
    //To set to input: pinMode(3, INPUT);
    //THIS IS P3, P3 is analog input 3, so when you are using analog read, you refer to it as 3.

    //sensorValue = analogRead(0); //Read P5
    //To set to input: pinMode(5, INPUT);
    //THIS IS P5, P5 is analog input 0, so when you are using analog read, you refer to it as 0.
}

Code

C/C++
Code
void setup() {
    //P0, P1, and P4 are capable of hardware PWM (analogWrite).
    pinMode(0, OUTPUT); //0 is P0, 1 is P1, 4 is P4 - unlike the analog inputs, 
                        //for analog (PWM) outputs the pin number matches the port number.
}

void loop() {
    analogWrite(0,255); //Turn the pin on full (100%)
    delay(1000);
    analogWrite(0,128); //Turn the pin on half (50%)
    delay(1000);
    analogWrite(0,0);   //Turn the pin off (0%)
    delay(1000);
}

Cdoe

C/C++
Code test
nt Speaker = 1;
void setup()

{

  pinMode(Speaker, OUTPUT);

}
void loop() {

  for (int i=0; i < 25; i++) {

    digitalWrite(Speaker, HIGH);

    delayMicroseconds(750);

    digitalWrite(Speaker, LOW);

    delayMicroseconds(750);

  }

    delay(50);

    for (int i=0; i < 25; i++) {

    digitalWrite(Speaker, HIGH);

    delayMicroseconds(500);

    digitalWrite(Speaker, LOW);

    delayMicroseconds(500);

  }

    delay(2000);

}

Code Snippet 2

//based on code from: http://www.technoblogy.com/show?20MO

//put together by Jeremy S. Cook 11/13/2019

 void setup() {}
 void loop() {

  for (int n=0; n<=12; n++) {

    note(n, 4);

    if (n!=4 && n!=11) n++;

    delay(500);

  }

  note(0, 0);

  delay(10000);

}

const int Output = 1;                                   // Can be 1 or 4
// Cater for 16MHz, 8MHz, or 1MHz clock:
const int Clock = ((F_CPU/1000000UL) == 16) ? 4 : ((F_CPU/1000000UL) == 8) ? 3 : 0;
const uint8_t scale[] PROGMEM = {239,226,213,201,190,179,169,160,151,142,134,127};
void note (int n, int octave) {

  int prescaler = 8 + Clock - (octave + n/12);

  if (prescaler<1 || prescaler>15 || octave==0) prescaler = 0;

  DDRB = (DDRB & ~(1<<Output)) | (prescaler != 0)<<Output;

  OCR1C = pgm_read_byte(&scale[n % 12]) - 1;

  GTCCR = (Output == 4)<<COM1B0;

  TCCR1 = 1<<CTC1 | (Output == 1)<<COM1A0 | prescaler<<CS10;

}

Code

C/C++
Code
void setup() {
    //All pins are capable of Digital output, though P5 is 3 V at HIGH instead of 5 V
    pinMode(0, OUTPUT); //0 is P0, 1 is P1, 2 is P2, etc. - unlike the analog inputs, for digital outputs the pin number matches.
}

void loop() {
    digitalWrite(0,HIGH); //Turn the pin HIGH (5 V)
    delay(1000);
    digitalWrite(0,LOW); //Turn the pin LOW (GND)
    delay(1000);
}

Code

C/C++
Code
http://digistump.com/wiki/digispark/tutorials/basics
#define kbd_tr_tr
#include "DigiKeyboard.h"

void setup() {
  DigiKeyboard.delay(2500);
  DigiKeyboard.sendKeyStroke(0);
}

void loop() {

  int data = analogRead(1);
  if ( data > 100)
  {
   
    if (data > 933) {
      DigiKeyboard.print("Button push1");
    }
    else if (data > 747) {
      DigiKeyboard.print("Button push2");
    }
    else if (data > 577) {
      DigiKeyboard.print("Button push3");
    }
    else if (data > 421) {
      DigiKeyboard.print("Button push4");
    }
    else if (data > 249) {
      DigiKeyboard.print("Button push5");
    }
    else  {
      DigiKeyboard.print("Button push6");
    }
     if (data > 223) {
      DigiKeyboard.print("Button push7");
    }
    else if (data > 200) {
      DigiKeyboard.print("Button push8");
    }
    else if (data > 176) {
      DigiKeyboard.print("Button push9");
    }
    else if (data > 156) {
      DigiKeyboard.print("Button push10");
   
    DigiKeyboard.sendKeyStroke(KEY_ENTER); 
    while (analogRead(1) > 100);
  }

}

Code

C/C++
Code
int sensorValue = 0;

void setup() {
    //All pins are capable of digital input.
    pinMode(0, INPUT); //0 is P0, 1 is P1, 2 is P2, etc. - unlike the analog inputs, for digital inputs the pin number matches.
}

void loop() {
    sensorValue = digitalRead(1); //Returns HIGH or LOW (true or false / 1 or 0).
}

Credits

Hamza Deniz YILMAZ

Hamza Deniz YILMAZ

18 projects • 7 followers
My YouTube Channel: https://www.youtube.com/channel/UCbete7WiB5nwUilmp1n7vFA
PCBWay

PCBWay

91 projects • 146 followers
We are a PCB and assembly manufacturer, As low as $5/10pcs and 24 hours delivery time. We are committed to helping creators build project.

Comments