Arnov Sharma
Published © LGPL

Kawaii PANDACORN PCB Badge

It's a panda... it's a unicorn, it's PANDACORN!

BeginnerFull instructions provided1 hour383

Things used in this project

Hardware components

Microchip Attiny13A
×1
PCBWay Custom PCB
PCBWay Custom PCB
×1
Arduino Nano R3
Arduino Nano R3
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

Gerber data for PCB

Schematics

sch

Code

code

C/C++
int switchPin = 4;     //4         
int led1Pin = 0;        //0

int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by


int val;                        
int val2;                       
int buttonState;                
int Mode ; //= 0;              

void setup() 
{
pinMode(switchPin, INPUT_PULLUP);    
pinMode(led1Pin, OUTPUT);
buttonState = digitalRead(switchPin); 
}

void loop(){
 
      val = digitalRead(switchPin);      // read input value and store it in val
      delay(10);                         // 10 milliseconds is a good amount of time
      val2 = digitalRead(switchPin);     // read the input again to check for bounces
      
      if (val == val2) {                 // make sure we got 2 consistant readings!
        if (val != buttonState) {          // the button state has changed!
          if (val == HIGH) {                // check if the button is pressed
            if (Mode == 0) {         
              Mode = 1;               
            } else {
                if (Mode == 1) {       
                Mode = 2;           
            } else {
                if (Mode == 2) {     
                Mode = 0;           
            } 
           }
          }
         }
        } 
        buttonState = val;                 // save the new state in our variable
      }

      // Now do whatever the lightMode indicates
      if (Mode == 0) {                       // FLIP FLOP
        digitalWrite(led1Pin, LOW);
      }

      if (Mode == 1) {
        analogWrite(led1Pin, brightness);
        brightness = brightness + fadeAmount;
        if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount;
  }
      }

      if (Mode == 2) {
        digitalWrite(led1Pin, HIGH);
        delay(50);
        digitalWrite(led1Pin, LOW);
        delay(50);
      }
}
      
    

Credits

Arnov Sharma

Arnov Sharma

269 projects • 275 followers
Just your average MAKER

Comments