diff --git a/README.md b/README.md index 81acfe7..3f3e643 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # A Guide to Astro Pi +**This is an archived resource.** The repo will remain available but the resource will no longer be maintained or updated. Some or all parts of the resource may no longer work. To see our latest resources, please visit [raspberrypi.org](http://www.raspberrypi.org). + ![Astro Pi](images/cover.png) This collection of guides and worksheets has been designed to provide you with a broad understanding of the Sense HAT and its capabilities. They could be used by teachers and students who have just entered the Astro Pi [Secondary School competition](http://astro-pi.org/secondary-school-competition/), or by anyone wanting to make the most of their Sense HAT. It will introduce you to what the board does, how to set it up, how to write your first program, and how to use the HAT's many features. @@ -10,9 +12,9 @@ This collection of guides and worksheets has been designed to provide you with a - [Assemble the Sense HAT](assemble.md) - [Sense HAT: emulation](emulation.md) - [Sense HAT: first program](program.md) -- [Sense HAT Python Cheatsheet](files/SenseHAT-Cheatsheet.pdf) +- [Sense HAT Python cheatsheet](files/SenseHAT-Cheatsheet.pdf) - [Getting started with Astro Pi learn resource](https://www.raspberrypi.org/learning/getting-started-with-astro-pi) -- [Sense HAT Pixel Workshop Worksheet](files/printable-worksheet.pdf) +- [Sense HAT pixel workshop worksheet](files/Sense-HAT-Worksheet-Digital.pdf) ## Sensors @@ -24,10 +26,10 @@ This collection of guides and worksheets has been designed to provide you with a ## Inputs & Outputs - [Joystick](inputs-outputs/joystick.md) -- [LED Matrix](inputs-outputs/led-matrix.md) +- [LED matrix](inputs-outputs/led-matrix.md) - [Buttons](inputs-outputs/buttons.md) ## Learn more about Astro Pi -- [The Official Astro Pi Website](http://astro-pi.org/) +- [The official Astro Pi website](http://astro-pi.org/) - Martin O'Hanlon has built a [virtual Astro Pi](http://www.stuffaboutcode.com/2015/05/interactive-minecraft-astro-pi.html) (Sense HAT) in Minecraft which you can interact with to explore the functionality of the board. diff --git a/files/Sense-HAT-Worksheet-Digital.pdf b/files/Sense-HAT-Worksheet-Digital.pdf new file mode 100644 index 0000000..cfe8ac5 Binary files /dev/null and b/files/Sense-HAT-Worksheet-Digital.pdf differ diff --git a/files/SenseHAT-Cheatsheet.pdf b/files/SenseHAT-Cheatsheet.pdf index 31bcb2e..11a1b3a 100644 Binary files a/files/SenseHAT-Cheatsheet.pdf and b/files/SenseHAT-Cheatsheet.pdf differ diff --git a/files/printable-worksheet.pdf b/files/printable-worksheet.pdf deleted file mode 100644 index 3ebd818..0000000 Binary files a/files/printable-worksheet.pdf and /dev/null differ diff --git a/learn.md b/learn.md new file mode 100644 index 0000000..8cf4e71 --- /dev/null +++ b/learn.md @@ -0,0 +1,5 @@ + +This resource covers elements from the following strands of the [Raspberry Pi Digital Making Curriculum](https://www.raspberrypi.org/curriculum/): + +- [Combine programming constructs to solve a problem](https://www.raspberrypi.org/curriculum/programming/builder) +- [Use basic digital, analogue, and electromechanical components](https://www.raspberrypi.org/curriculum/physical-computing/creator) diff --git a/sensors/movement.md b/sensors/movement.md index b7c887d..c3d22e2 100644 --- a/sensors/movement.md +++ b/sensors/movement.md @@ -4,7 +4,7 @@ The Sense HAT has a movement sensor called an IMU, which can measure the kind of ## What is an IMU? -IMU stand for Inertial Measurement Unit. It's actually three sensors in one: +IMU stands for Inertial Measurement Unit. It's actually three sensors in one: - A gyroscope (measures momentum and rotation) - An accelerometer (measures acceleration forces and can be used to find the direction of gravity) @@ -38,9 +38,9 @@ The image above shows where these axes are in relation to the Sense HAT. Let's download and run a 3D demo program to explore this. -## Apollo Soyuz Demo +## Apollo-Soyuz Demo -The image below shows the Apollo Soyuz module that was used to take humans to the surface of the moon during the 1970s. The 3D demo we're going to play with shows this same spacecraft (but with less detail). +The image below shows the Apollo-Soyuz module that was formed when the USA and USSR met in orbit around the earth in 1975. The 3D demo we're going to play with shows this same spacecraft (but with less detail). ![](images/apollo_soyuz.jpg) @@ -72,15 +72,15 @@ Press `Esc` to exit the demo. Let's try a simpler version of this ourselves in c 1. Select `File > New Window` and enter the following code: ```python - from sense_hat import SenseHat - sense = SenseHat() - sense.clear() - - o = sense.get_orientation() - pitch = o["pitch"] - roll = o["roll"] - yaw = o["yaw"] - print("pitch {0} roll {1} yaw {2}".format(pitch, roll, yaw)) + from sense_hat import SenseHat + sense = SenseHat() + sense.clear() + + o = sense.get_orientation() + pitch = o["pitch"] + roll = o["roll"] + yaw = o["yaw"] + print("pitch {0} roll {1} yaw {2}".format(pitch, roll, yaw)) ``` 1. Select `File > Save` and choose a file name for your program. @@ -96,6 +96,9 @@ Press `Esc` to exit the demo. Let's try a simpler version of this ourselves in c pitch 356.35723002363454 roll 303.4986602798494 yaw 339.19880231669873 ``` + + + 1. We don't need all the numbers after the decimal point so let's round them off. Just before the `print("pitch %s roll %s yaw %s" % (pitch, roll, yaw))` line, add these lines below: ```python @@ -109,21 +112,23 @@ Press `Esc` to exit the demo. Let's try a simpler version of this ourselves in c 1. It would be good to monitor the axis values changing during movements, so let's put your code into a `while` loop and run it again: ```python - while True: - o = sense.get_orientation() - pitch = o["pitch"] - roll = o["roll"] - yaw = o["yaw"] + while True: + o = sense.get_orientation() + pitch = o["pitch"] + roll = o["roll"] + yaw = o["yaw"] - pitch = round(pitch, 1) - roll = round(roll, 1) - yaw = round(yaw, 1) + pitch = round(pitch, 1) + roll = round(roll, 1) + yaw = round(yaw, 1) - print("pitch {0} roll {1} yaw {2}".format(pitch, roll, yaw)) + print("pitch {0} roll {1} yaw {2}".format(pitch, roll, yaw)) ``` 1. Move the Pi around in your hand and you should see the numbers changing. See if you can just make one axis change by moving only in the pitch direction for example. Do this for all three axes. Press `Ctrl - C` to stop the program. + + ## Display orientation on the LED matrix 1. Displaying something which is 3D in a 2D way is always a challenge, especially when your screen is only 8 x 8 pixels in size. One way which might work well is to have one LED for each axis and then make them move in different ways. For example: @@ -183,29 +188,32 @@ Press `Esc` to exit the demo. Let's try a simpler version of this ourselves in c So the length is 28. If we divide 28 by 360 we have a ratio between, say, the yaw measurement and the positions in our list (how far around the edge we are). We can then get the sequential pixel number out of the list at the calculated position, work out its coordinate and then switch the LED on! Like this: ```python - from sense_hat import SenseHat + from sense_hat import SenseHat - sense = SenseHat() - sense.clear() + sense = SenseHat() + sense.clear() - edge = [0, 1, 2, 3, 4, 5, 6, 7, 15, 23, 31, 39, 47, 55, 63, 62, 61, 60, 59, 58, 57, 56, 48, 40, 32, 24, 16, 8] - length = len(edge) - ratio = length / 360.0 + edge = [0, 1, 2, 3, 4, 5, 6, 7, 15, 23, 31, 39, 47, 55, 63, 62, 61, 60, 59, 58, 57, 56, 48, 40, 32, 24, 16, 8] + length = len(edge) + ratio = length / 360.0 - while True: - o = sense.get_orientation() - pitch = o["pitch"] - roll = o["roll"] - yaw = o["yaw"] + while True: + o = sense.get_orientation() + pitch = o["pitch"] + roll = o["roll"] + yaw = o["yaw"] - yaw_list_position = int(yaw * ratio) + yaw_list_position = int(yaw * ratio) - yaw_pixel_number = edge[yaw_list_position] + yaw_pixel_number = edge[yaw_list_position] - y = yaw_pixel_number // 8 - x = yaw_pixel_number % 8 + y = yaw_pixel_number // 8 + x = yaw_pixel_number % 8 - sense.set_pixel(x, y, 255, 255, 255) + sense.set_pixel(x, y, 255, 255, 255) ``` + + + 1. What you'll notice is that the above code only turns LEDs on, you'll need to figure out how to turn them off yourself. Try having a variable for the previous `x` and `y` from the last time around the loop and if this is different from the new `x` and `y` you use `set_pixel` to set the LED to black.