Transcript decimal

What is your age in binary?
I am 12.
12 is a
decimal
number
In binary I am
1100
Canto
you
work out
Use this table
convert
a your
own age
decimal number
intoinabinary?
binary number.
8
1
4
2
1
1
0
0
To make 12 I need to add
8 and 4.
Put a 1 under these numbers.
Put a 0 under the numbers that
are not needed
Can you make your micro:bit count up
to 7 in binary?
Press one of these
to make it count up
from 0 to 7
Show the number
in decimal on here.
0
1
4
3V
2
2
1
Write the number in
binary on the pins
Gnd
If Button is pressed:
Increment variable “decimal” by 1
Output Decimal
Assign variable “binary” to same value as “decimal”
if “binary” >= 4
Make pin0 High
Subtract 4 from “binary”
else
Make pin0 Low
if “binary” >= 2
Make pin1 High
Subtract 2 from “binary”
else
Make pin1 Low
if “binary” = 1
Make pin2 High
else
Make pin2 Low
https://www.microbit.co.uk/dlrjhk
Can you make your micro:bit talk to
a Raspberry Pi over the GPIO pins?
Make some GPIO connector wires
•
•
•
•
•
You will need
Male to Female jumpers
Paperclips
Tin foil
Sticky Tape
Put the paperclip, tin foil and male end
of the jumper together.
• Make sure the two loops of the paperclip are
pointing outwards.
Wrap it all up tightly with the tinfoil.
Wrap the tinfoil up with sticky tape.
Make sure you leave the paperclip
clear.
Connect the wires to Gnd, pin0, pin1, pin2.
Use a bit more sticky tape to secure them in
place.
Connect the other ends of the jumpers to the
Raspberry Pi GPIO pins.
Micro:bit
gnd pin
Micro:bit
pin0
Micro:bit
pin1
Micro:bit
pin2
Can you program Scratch so that the
cat says in decimal the binary number
sent from the micro:bit?
DISCUSS
Forwards
Backwards
Left
Right
Can you give the
raspberry pi robot
more senses using the
micro:bit?
How can you get all
that data across those
3 wires?
Temperature
Light Level
Compass Heading
Buttons pushed
Tilt
Shake