Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Arnov Sharma
Published © LGPL

Majin Vegeta on a PCB

Made a Vegeta Inspired PCB Art, LEDs on it is driven by a Mosfet IC and controlled by an Attiny13A

IntermediateFull instructions provided1 hour309

Things used in this project

Hardware components

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

Software apps and online services

Fusion
Autodesk Fusion
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Gerber data for PCB

body

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);
      }
}
     

Credits

Arnov Sharma
340 projects • 346 followers
Just your average MAKER
Contact

Comments

Please log in or sign up to comment.