This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-11-14 13:46:09

Llamalover
Scratcher
Registered: 2007-05-18
Posts: 100+

7 Segment Display/ Afficheur & Décodeur 7 Segments

7 Segment Display/ Afficheur & Décodeur 7 Segments

http://scratch.mit.edu/projects/Llamalover/2908367

This is the first project I've uploaded in 2 and a half years!

Adjust the number slider, and the display changes accordingly!

While this could be done much more simply using costumes, I decided to use some things I've learnt in my EEA (Electronics, electrotechnics and automatisms) class to create this.

First the number is converted from decimal (base 10) to binary (base 2). That's the digits you see in the variable 'Binary Code'. Because Scratch doesn't show any 'unnecessary' zeroes, I also created a list with each digit of the binary code as an item. This way even if the binary is 0000, there's still 4 digits. Using things I learnt in class, such as logic operands, Karnaugh tables, and de Morgan's law (nb: I take this class in French, so give me a shout if I've mistranslated any terms!) to work out a logic equation for each of the 7 segments (the lines that form the number) which determine whether that line is hidden or showing. Put them all together, and the various combinations of hidden or visible sprites creates a number!

This is how many LCD displays work (like in your alarm clock, or digital watch, etc.)

If anyone's interested in this sort of thing (which I find great fun!  wink  ), I could create a step-by-step how to project.

And please feel free to download this, mess around with the code, remix it, or use it in your projects!

(By the way, the code that converts the decimal number into binary might be useful, so take that if you need it!  smile  )

(and yes, this is a copy-paste of the project notes!  wink  )

Last edited by Llamalover (2012-11-14 16:07:59)


Be nice, I'm an old lady  wink

Offline

 

Board footer