3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Faraday For Fun: An Electronic Batteryless Dice

Step 7Control Software

/*Electronic battery Less Dice*/
/*Dhananjay Gadre*/
/*20th September 2007*/
/*Tiny13 Processor @ 128KHz internal RC oscillator*/
/*7 LEDs connected as follows
LED0 - PB1
LED1, 2 - PB2
LED3, 4 - PB3
LED5, 6 - PB4

D3 D2
D5 D0 D6
D1 D4

Pulse input from coil is on PB0
*/

#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include<avr/pgmspace.h>

const char ledcode[] PROGMEM= {0xfc, 0xee, 0xf8, 0xf2, 0xf0, 0xe2, 0xfe};

main()
{
unsigned char temp=0;
int count=0;

DDRB=0xfe; /*PB0 is input*/
TCCR0B=2; /*divide by 8*/
TCCR0A=0;
TCNT0= 0;

PORTB=254; /*disable all LEDs*/

while(1)
{
/*wait for pulse to go high*/
while ( (PINB & 0x01) == 0);
_delay_loop_2(50);

/*wait for pulse to go low*/
while ( (PINB & 0x01) == 0x01);
_delay_loop_2(50);

count=5000;
while ( (count > 0) && ((PINB &0x01) ==0))
{count--;
}

if(count ==0) /* no more pulse so display a random number*/
{

PORTB=0xfe; /*all LEDs off*/
_delay_loop_2(10000);

temp=TCNT0;
temp= temp%6;
temp =pgm_read_byte(&ledcode[temp]);
PORTB=temp;
}

}

}
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
33
Followers
9
Author:Gadre