Laser pointer discussion. Read/write reviews of laser pointers and laser pointer companies. Learn about all types of laser pointers and lasers





Welcome to Laser Pointer Forums! If you are looking for a laser pointer or want to compare different laser pointer companies, you may want to check out the LPF Laser Pointer Company Database. The link will open in a new window for your convenience.








Green Laser Pointers by Category Blue Laser Pointers by Category Red Laser Pointers by Category
Yellow Laser Pointers by Category Violet Laser Pointers by Category Orange Laser Pointers by Category
Top Laser Pointers by Power - 1 Watt+ Top Laser Pointers by Power - 500mW+ Top Laser Pointers by Power - 250mW+
Laser Pointer Database High Power Laser Pointers Laser Pointer Diodes
Laser Technology Laser Pointer Parts Lasers by Wavelength
Top 10 Laser Pointer Companies Laser Pointer Company Database Visible Beam Laser Pointers


One laser store meets all your needs

























Go Back   Laser Pointer Forums - Discuss Laser Pointers > Lasers > Tutorials, Help & Repairs



LPF List of Laser Pointer Companies (link opens new window)



Reply
 
LinkBack Thread Tools Display Modes
Old 11-26-2014, 03:08 AM #97
rhd's Avatar
rhd rhd is offline
Class 4 Laser
 
Join Date: Dec 2010
Posts: 8,491
Rep Power: 1392
rhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond repute
rhd rhd is offline
Class 4 Laser
rhd's Avatar
 
Join Date: Dec 2010
Posts: 8,491
Rep Power: 1392
rhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond repute
Default Re: Anyone familiar with Attiny13 programming?

Dramatically rewrote the code, and it works great! I even added a rapid cycling mode.

If there's any problem (and I can live with this for now), it's that there's piss poor entropy to the randomness approach (probably because storing a value of 1-255 to use as the random seed just doesn't produce the needed entropy). I can detect the patterns.

Code:
  
#include <EEPROM.h> // include the EEPROM Memory library
boolean pinOptions[8][3] = { // Array of pin combinations (1 = on, 0 = off)
  {1,1,1},
  {1,0,0},
  {1,1,0},
  {0,1,0},
  {0,1,1},
  {0,0,1},
  {1,0,1},
  {0,0,0}
};

byte ButtonPin = 3; // see pinout
byte ColorOnePin = 0; // see pinout
byte ColorTwoPin = 1; // see pinout
byte ColorThreePin = 2; // see pinout
byte MemVar;
byte RandVar;
byte MemoryLocation = 1;
byte RandLocation = 0;
byte ButtonPinState;
byte ColorChoice;

void setup (){ // this subroutine runs once upon startup
  pinMode (0, OUTPUT); // set pin 0 to output
  pinMode (1, OUTPUT); // set pin 1 to output
  pinMode (2, OUTPUT); // set pin 2 to output
  pinMode (3, INPUT); // set pin 3 to input
  // Read memvar
  MemVar = 1;
  MemVar = EEPROM.read(MemoryLocation);
  if (MemVar > 9){ 
     MemVar = 1; // 
  }
  if (MemVar == 8){
    RandVar = EEPROM.read(RandLocation);
    randomSeed(RandVar);
    setRandomColor(); 
  }
  else if (MemVar == 9){
    RandVar = EEPROM.read(RandLocation);
    randomSeed(RandVar);
    ColorChoice = random(2, 7);
    setColor(); 
  }
  else
  {
    ColorChoice = MemVar;
    setColor();
  }
}

void loop(){ // this subroutine runs continuously after setup finishes
  ButtonPinState = digitalRead(ButtonPin);  // read ButtonPin to ButtonPinState  
  if (ButtonPinState == HIGH){ // when ButtonPinState is HIGH...
    ++ MemVar; // increment memory variable
    if (MemVar > 9){ // on 9th button press...
      MemVar = 1; // reset color
    }
    EEPROM.write(MemoryLocation, MemVar);
    // Normal mode for colors 1 through 7
    if (MemVar < 8){
      ColorChoice = MemVar;
      setColor();
      delay(300);
    } 
    // Random color mode (no cycling)
    else if (MemVar == 8){
      blinkAll();
      randomSeed(millis());
      setRandomColor();      
    }
    // Random color mode (rapid cycling) - Indicate that we're entering the mode
    else if (MemVar == 9){
      blinkAll();
    }
  }
  // Random color mode (rapid cycling) 
  if (MemVar == 9){
      randomSeed(millis());
      ColorChoice = random(2, 7);
      setColor();
      delay(50);
  }
}

void blinkAll(){
  for (int i=0; i <= 4; i++){
    ColorChoice = 8;
    setColor();
    delay(20);
    ColorChoice = 1;
    setColor();
    delay(20);      
  }
}

void setRandomColor(){
  ColorChoice = random(2, 7);
  setColor(); 
  RandVar = random(1, 255);
  EEPROM.write(RandLocation, RandVar);  
}

void setColor(){
  digitalWrite(ColorOnePin, pinOptions[ColorChoice-1][0]);
  digitalWrite(ColorTwoPin, pinOptions[ColorChoice-1][1]);
  digitalWrite(ColorThreePin, pinOptions[ColorChoice-1][2]);  
}


__________________
CURRENT WAVELENGTHS:
405|441|450|467|473|495|505|520|532|556|PGLRG|589|594|632|638|660


SAFETY & IMPORTANT READING (threads authored and contributed to by various members of LPF):
- Federal Aviation Administration - Laser Safety Initiative (link)
- Info release from Laserglow - Default Canadian restrictions on portable lasers (link)
- The Necessity of Safety Goggles (link)


Last edited by rhd; 11-26-2014 at 04:37 AM.
rhd is offline   Reply With Quote







LPF List of Laser Pointer Companies (link opens new window)







Old 11-26-2014, 02:04 PM #98
Sigurthr's Avatar
Class 3B Laser
 
Join Date: Dec 2011
Location: Michigan's U.P.
Posts: 4,382
Rep Power: 873
Sigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond repute
Sigurthr Sigurthr is offline
Class 3B Laser
Sigurthr's Avatar
 
Join Date: Dec 2011
Location: Michigan's U.P.
Posts: 4,382
Rep Power: 873
Sigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond repute
Default Re: Anyone familiar with Attiny13 programming?

Code looks great! It's nice to see some of my old "clunking" code made it into the final build, hehe. =P In all seriousness though there's some genius solutions in there, excellent work.

Btw, can you link which usb programmer you went with in the end? I might pick one up to save me the trouble of having to pull my arduino from use every time I need to flash an attiny.

Oh, when you finish this build fully, I really think you NEED to submit it to a DIY/Hacker magazine/blog/etc. It's visually and technically stunning enough to really bring in recognition and amazement.

edit: Oh and it looks like you got the eeprom read/write lockup fixed. Did you figure out what the problem was? Probably was it just being initially read as 0, eh?
__________________
Amateur Multispectral Photographer - [X-Ray, UV, Vis, IR]
Amateur Electrical Engineer
Autodidact
Tesla Coil Expert

Last edited by Sigurthr; 11-26-2014 at 02:10 PM.
Sigurthr is offline   Reply With Quote
Old 11-27-2014, 05:29 AM #99
rhd's Avatar
rhd rhd is offline
Class 4 Laser
 
Join Date: Dec 2010
Posts: 8,491
Rep Power: 1392
rhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond repute
rhd rhd is offline
Class 4 Laser
rhd's Avatar
 
Join Date: Dec 2010
Posts: 8,491
Rep Power: 1392
rhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond reputerhd has a reputation beyond repute
Default Re: Anyone familiar with Attiny13 programming?

Got some smooth fading color cycling, without hardware PWM

Will try to post a video.

Code:
byte ColorRED = 0; 
byte ColorGREEN = 1; 
byte ColorBLUE = 2;
byte StageCount = 20;
byte PWMCount = 1;
byte ColorFade;

void setup (){
  pinMode (0, OUTPUT); 
  pinMode (1, OUTPUT); 
  pinMode (2, OUTPUT); 
  pinMode (3, INPUT); 

  // Fade in RED
  ColorFade = ColorRED;
  FadeIn();
}

void loop(){ 
  ColorCycle();
}

void ColorCycle(){
  ColorFade = ColorBLUE;
  FadeIn();
  ColorFade = ColorRED;
  FadeOut();
  ColorFade = ColorGREEN;
  FadeIn();
  ColorFade = ColorBLUE;
  FadeOut();  
  ColorFade = ColorRED;
  FadeIn();
  ColorFade = ColorGREEN;
  FadeOut();    
}

void FadeIn(){  
  for (int j=0; j <= StageCount; j++){
    for (int i=0; i <= PWMCount-1; i++){
      digitalWrite(ColorFade, 1);
      delay(j);
      digitalWrite(ColorFade, 0);
      delay(StageCount+1-j);
    }
  }
  digitalWrite(ColorFade, 1);
}

void FadeOut(){  
  for (int j=0; j <= StageCount; j++){
    for (int i=0; i <= PWMCount-1; i++){
      digitalWrite(ColorFade, 1);
      delay(StageCount+1-j);
      digitalWrite(ColorFade, 0);
      delay(j);
    }
  }
  digitalWrite(ColorFade, 0);
}
__________________
CURRENT WAVELENGTHS:
405|441|450|467|473|495|505|520|532|556|PGLRG|589|594|632|638|660


SAFETY & IMPORTANT READING (threads authored and contributed to by various members of LPF):
- Federal Aviation Administration - Laser Safety Initiative (link)
- Info release from Laserglow - Default Canadian restrictions on portable lasers (link)
- The Necessity of Safety Goggles (link)


Last edited by rhd; 11-27-2014 at 05:30 AM.
rhd is offline   Reply With Quote
Old 11-27-2014, 02:42 PM #100
Class 1M Laser
 
Join Date: Sep 2007
Location: Nashville, TN
Posts: 169
Rep Power: 21
jayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud of
jayhawker08 jayhawker08 is offline
Class 1M Laser
 
Join Date: Sep 2007
Location: Nashville, TN
Posts: 169
Rep Power: 21
jayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud ofjayhawker08 has much to be proud of
Default Re: Anyone familiar with Attiny13 programming?

Quote:
Originally Posted by rhd View Post
Got some smooth fading color cycling, without hardware PWM
Very nice work! If you get the button interrupt working, you should be able to put that back in without slowing it down at all.
jayhawker08 is offline   Reply With Quote
Reply





Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On











Loading








Green Laser Pointers by Category Blue Laser Pointers by Category Red Laser Pointers by Category
Yellow Laser Pointers by Category Violet Laser Pointers by Category Orange Laser Pointers by Category
Top Laser Pointers by Power - 1 Watt+ Top Laser Pointers by Power - 500mW+ Top Laser Pointers by Power - 250mW+
Laser Pointer Database High Power Laser Pointers Laser Pointer Diodes






Privacy Policy | Advertising Disclaimer | Terms of Use


 


All times are GMT. The time now is 06:12 AM.


Powered by: vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO
Privacy Policy | Advertising Disclaimer | Terms of Use
Copyright (C) 2017 Laser Pointer Forums, LLC