7-Segment dice

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Re: 7-Segment dice

Postby ober » Wed Jan 26, 2011 10:08 pm

pic16 WROTE: is it cytron have a class for study programming?


We do have workshop for PIC microcontroller, yet it is based on C programming, and it is very packed for a beginner :D

It is good to see you are taking initiative to learn, keep it going and we really hope to see more project and more members helping up. Do help up the others as others helped you.

BTW, I have send your video link to our facebook admin, they have posted at Cytron facebook wall. Hope your video can motivate and encourage more to start.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: 7-Segment dice

Postby shahrul » Wed Jan 26, 2011 10:40 pm

pic16 WROTE:is it cytron have a class for study programming?

Get free coding here, but you need to have intention to study on your own.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: 7-Segment dice

Postby pic16 » Fri Jan 28, 2011 11:52 am

ober WROTE:
pic16 WROTE: is it cytron have a class for study programming?


We do have workshop for PIC microcontroller, yet it is based on C programming, and it is very packed for a beginner :D

It is good to see you are taking initiative to learn, keep it going and we really hope to see more project and more members helping up. Do help up the others as others helped you.

BTW, I have send your video link to our facebook admin, they have posted at Cytron facebook wall. Hope your video can motivate and encourage more to start.




will it expensive? :roll: :oops:
i'm poor in english and just an electronic hobbyist.
pic16
Amateur
 
Posts: 135
Joined: Tue Jan 04, 2011 2:28 pm
Location: Earth

Re: 7-Segment dice

Postby pic16 » Fri Jan 28, 2011 11:53 am

shahrul WROTE:
pic16 WROTE:is it cytron have a class for study programming?

Get free coding here, but you need to have intention to study on your own.



nice website....
i will bookmark it..
i'm poor in english and just an electronic hobbyist.
pic16
Amateur
 
Posts: 135
Joined: Tue Jan 04, 2011 2:28 pm
Location: Earth

Re: 7-Segment dice

Postby ABSF » Sun Jan 30, 2011 5:04 pm

ober WROTE:Just my sudden thought, kind of agree with generating the number from key press.

Though is not really random, but if the microcontroller is running at 20MHz, and each instruction is executed at 200ns. If changing the number at 7-segment take a few instructions, it will take around 1us to 2us. Basically no one cannot see and also predict the number that will appear on 7seg when it release the keypress.

Therefore it become random :)


Myke Predko has a smarter way to generate random number. Page 128 of my "Evil Genius" book has an example on how to generate random number using TMR0. The result is an integer between 0 and 255:

OPTION = 0b01001111; // Run TMR0 From PIC MCU Clock
;
;
; when random number is needed:
;
i = TMR0; // Save TMR0 Value
if (i > 100) // Convert TMR0 Value to Decimal
LCDWrite((i / 100) + '0', 1);
else // No Hundreds to Display
LCDWrite(' ', 1);
if (i > 10)
{
i = i % 100; // Not Greater than 10
LCDWrite((i / 10) + '0', 1);
}
else
LCDWrite(' ', 1);
LCDWrite((i % 10) + '0', 1);

As the program is copyrighted. I can only extract a portion out of the whole program.

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: 7-Segment dice

Postby Brian Griffin » Sun Jan 30, 2011 6:16 pm

ABSF WROTE:
ober WROTE:Just my sudden thought, kind of agree with generating the number from key press.

Though is not really random, but if the microcontroller is running at 20MHz, and each instruction is executed at 200ns. If changing the number at 7-segment take a few instructions, it will take around 1us to 2us. Basically no one cannot see and also predict the number that will appear on 7seg when it release the keypress.

Therefore it become random :)


Myke Predko has a smarter way to generate random number. Page 128 of my "Evil Genius" book has an example on how to generate random number using TMR0. The result is an integer between 0 and 255:

OPTION = 0b01001111; // Run TMR0 From PIC MCU Clock
;
;
; when random number is needed:
;
i = TMR0; // Save TMR0 Value
if (i > 100) // Convert TMR0 Value to Decimal
LCDWrite((i / 100) + '0', 1);
else // No Hundreds to Display
LCDWrite(' ', 1);
if (i > 10)
{
i = i % 100; // Not Greater than 10
LCDWrite((i / 10) + '0', 1);
}
else
LCDWrite(' ', 1);
LCDWrite((i % 10) + '0', 1);

As the program is copyrighted. I can only extract a portion out of the whole program.

Allen


The random number part from the "Flickering Candle" experiment in his book is also very useful. He is using the Linear Shift Feedback Register (LFSR). The idea isn't all that new, but it's a pretty neat trick. :D
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: 7-Segment dice

Postby vonskyes » Wed Apr 30, 2014 2:48 am

aurora WROTE:All of us here understand exactly how you feel, cause once upon a time, we never know how to write a code either! :ugeek:
We grew from books, internet, reading, and basically experiment (and that was the toughest parts!). Personally, I learn from one book I get from the library. My first program is just a simple 4-5 lines of code blinking 1 LED, copy paste from the book. As I grow and write better program, I gave up few times, take a break for few weeks/months, and then start picking up from where I left. And I am still working on the same project since.. :? ;)

Starting is most difficult, but once you have the first success, it become easier. But still, it is easiest to say I don't know please help. :roll:


i am kicking off my programming life the same way too....*passion of the codes*. with you guys i know i am going to get far.
vonskyes
Fledgling
 
Posts: 1
Joined: Wed Apr 30, 2014 2:21 am

Previous

Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 2 guests