10
What are these? What are these?

What are these?. Binary Clock ICE3M May 7, 2007 Ms. Nelson

Embed Size (px)

Citation preview

Page 1: What are these?. Binary Clock ICE3M May 7, 2007 Ms. Nelson

What are these?What are these?

Page 2: What are these?. Binary Clock ICE3M May 7, 2007 Ms. Nelson
Page 3: What are these?. Binary Clock ICE3M May 7, 2007 Ms. Nelson

Binary ClockBinary Clock

ICE3MICE3M

May 7, 2007May 7, 2007

Ms. NelsonMs. Nelson

Page 4: What are these?. Binary Clock ICE3M May 7, 2007 Ms. Nelson

Telling Time in BinaryTelling Time in Binary

1 or 0

2 or 0

4 or 08 or 0

16 or 032 or 0

1 + 4 + 8 + 32 = 45 seconds!

Similarly, the clock is currently showing

4 + 8 = 12 for the hour, and

4 + 2 + 1 = 7 for the minutes

Therefore the current time is 12:07 and 45 seconds.

Page 5: What are these?. Binary Clock ICE3M May 7, 2007 Ms. Nelson

Computers and StorageComputers and Storage

Everything inside your computer is boiled Everything inside your computer is boiled down to tiny on/off switchesdown to tiny on/off switches

Traditionally, we use 0 for off and 1 for onTraditionally, we use 0 for off and 1 for on Ever noticed this on on/off switches?Ever noticed this on on/off switches?

Numbers are stored this way tooNumbers are stored this way too

Page 6: What are these?. Binary Clock ICE3M May 7, 2007 Ms. Nelson

Counting with 0’s and 1’sCounting with 0’s and 1’s

Pretend we only had 0’s and 1’s to work Pretend we only had 0’s and 1’s to work with, and not 2, 3, 4, 5, 6, 7, 8, 9.with, and not 2, 3, 4, 5, 6, 7, 8, 9.

How many numbers can you come up How many numbers can you come up with?with? 0, 1, 10, 11 (but not 12, 13, 14… have to 0, 1, 10, 11 (but not 12, 13, 14… have to

skip all the way up to 99)skip all the way up to 99) 100, 101, 110, 111100, 101, 110, 111 1000…. 1000…. can you continue this pattern?can you continue this pattern?

Page 7: What are these?. Binary Clock ICE3M May 7, 2007 Ms. Nelson

Matching UpMatching Up

00 00

11 11

22 1010

33 1111

44 100100

55 101101

66 110110

77 111111

88 10001000

99 10011001

1010 10101010

1111 10111011

1212 11001100

1313 11011101

1414 11101110

1515 11111111

1616 1000010000

1717 1000110001

1818 1001010010

1919 1001110011

2020 1010010100

2121 1010110101

2222 1011010110

2323 1011110111

2424 1100011000

2525 1100111001

2626 1101011010

Page 8: What are these?. Binary Clock ICE3M May 7, 2007 Ms. Nelson

The Power of the Powers The Power of the Powers of 2of 2

1 (decimal) 1 (decimal) ≈≈ 1 (binary) 1 (binary) ≈≈ 2 200

10 (decimal) 10 (decimal) ≈≈ 2 (binary) 2 (binary) ≈≈ 2 211

100 (decimal) 100 (decimal) ≈≈ 4 (binary) 4 (binary) ≈≈ 2 222

1000 (decimal) 1000 (decimal) ≈≈ 8 (binary) 8 (binary) ≈≈ 2 233

Any number can be expressed as a sum Any number can be expressed as a sum of powers of 2of powers of 2 e.g. 13 = 8 + 4 + 1 = 2e.g. 13 = 8 + 4 + 1 = 23 + 3 + 222 + 2 + 220 0 ≈≈ 1101 (bin) 1101 (bin) This is your shortcut!This is your shortcut!

Page 9: What are these?. Binary Clock ICE3M May 7, 2007 Ms. Nelson

Back to the TimeBack to the Time

It’s now 2:26 and 34 secondsIt’s now 2:26 and 34 seconds How do we represent that?How do we represent that?

2 becomes 102 becomes 10 26 becomes 1101026 becomes 11010 34 becomes 10001034 becomes 100010

The current time is: 10 11010 100010The current time is: 10 11010 100010

Page 10: What are these?. Binary Clock ICE3M May 7, 2007 Ms. Nelson

Your Task…Your Task…

Write a program in Turing that…Write a program in Turing that… Gets the current time from the systemGets the current time from the system

Look in the command reference for “Time”Look in the command reference for “Time”

Prints it out to the console in binary formatPrints it out to the console in binary format e.g., 2:26:34 prints out as:e.g., 2:26:34 prints out as:

10 10 11010 11010 100010100010

Our next project will involve LED lightsOur next project will involve LED lights