pov success

MiniPOV4 and previous versions

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
jpersonna
 
Posts: 10
Joined: Wed Jan 13, 2010 12:35 pm

pov success

Post by jpersonna »

Thanks for a great kit. It went together easy with the online instructions, and works: Win7, oldish Dell, actual Serial ... though I just noticed that I didn't actually solder one end of D3. Apparently this is optional.

Since I'm a total beginner I soldered the Elenco practice kit SP-3B first. That was nice, progressing from easy to hard with 100 or whatever solder points. A version of that with a more modern feel might be a good product for the "maker" constellation.

Oh, and for some reason I just like to watch LEDs count:

Code: Select all

#include <avr/io.h>      // this contains all the IO port definitions
#include <util/delay.h>

int main(void) {

  // set port B to output only
		
  DDRB = 0xFF;

  // count up port b with 1/2 sec delay
		
  PORTB = 0;
  
  while (1) {
  	
    _delay_ms((double)500);
	
	if (PORTB == 255)
		PORTB = 0;
	else
		PORTB++;
		
  }

  
}
Dumb, I know, but strangely fascinating.

I assume that I could have just kept incrementing PORTB and let it wrap .. that carry would end up somewhere.

jpersonna
 
Posts: 10
Joined: Wed Jan 13, 2010 12:35 pm

Re: pov success

Post by jpersonna »

Heh, I could change the delay to 5.6 minutes and call it a wrist-watch. B8(00000000) to B8(11111111) in 24 hours, with B8(10000000) as high noon.

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: pov success

Post by mtbf0 »

no need for this bit...

Code: Select all

   if (PORTB == 255)
      PORTB = 0;
   else
      PORTB++;

Code: Select all

  PORTB++;
will suffice. 255 + 1 is zero.

jpersonna
 
Posts: 10
Joined: Wed Jan 13, 2010 12:35 pm

Re: pov success

Post by jpersonna »

Thanks, that's what I was asking about at the end, the wrap and carry. I guess not knowing the architecture I wasn't sure the carry wouldn't be pushed somewhere else. I recall some processors with paired registers and such.

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: pov success

Post by mtbf0 »

all of the i/o registers on the tiny2313 are 8 bits except for a couple involving timer1, which is a 16-bit timer.

only thing funner than blinking leds is fading leds. gives you a chance to play with timer1, too. stick drinking straws over the leds for diffusers.

jpersonna
 
Posts: 10
Joined: Wed Jan 13, 2010 12:35 pm

Re: pov success

Post by jpersonna »

Cool, I'll try that.

Locked
Please be positive and constructive with your questions and comments.

Return to “MiniPOV”