Advertisement
UnaClocker

ATTiny Christmas Ornament

Dec 18th, 2011
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. // ATTiny85 based Christmas ornament
  2. // Written by Brian Gosney aka UnaClocker December 2011
  3. // Creative Commons FTW
  4.  
  5. void setup() {
  6.   pinMode(0, OUTPUT); // Clock pin
  7.   pinMode(1, OUTPUT); // Data pin
  8.   pinMode(2, OUTPUT); // Latch pin
  9.   pinMode(3, INPUT); // Analog input for randomizer
  10.   randomSeed(analogRead(3)); // Doesn't NEED to be random, but why not..  
  11. }
  12.  
  13. void loop() {
  14.   pinMode(2, LOW); // Drop the latch pin
  15.   delay(20);
  16.   shiftOut(1, 0, MSBFIRST, random(255)); // shift out a random number, causing random lights to come on.
  17.   delay(20);
  18.   pinMode(2, HIGH); // Raise the latch, activating the new set of lights.
  19.   int temp = random(15)+1; // Random number between 1 and 15
  20.   delay(temp*100); // Delay between 100 and 1500ms.
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement