Skip to content

Commit 108a59c

Browse files
committed
added the new memory
2 parents f26693c + bcce0f7 commit 108a59c

File tree

6 files changed

+75
-89
lines changed

6 files changed

+75
-89
lines changed

README.md

+41-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,52 @@
11
# python_pi_club
22
This is the repo for the Code Next Connect club - Python on the Pi
3+
You will need a Raspberry Pi (3, 4, 400) and a Sense HAT unit.
34

45
## Install libraries
6+
In your Terminal, run these commands to install the necessary libraries:
57

68
#### Sense Hat
9+
```bash
10+
$ sudo apt-get update
11+
$ sudo apt-get install sense-hat
12+
$ sudo reboot
713

14+
```
15+
#### Anvil
16+
```bash
17+
$ sudo pip3 install anvil-uplink
18+
19+
```
20+
This course will use Python 3, so make sure to use pip3 above.
821
## What's in the Repo?
9-
Starter files for the Python on Pi Club.
22+
Starter files for the Python on Pi Club, as well as fully-built examples. There are also some warm-ups and basic challenges.
1023

1124
## Memory
12-
The first game, introduced in session 1. The objective is to reproduce the sequence of the arrows by moving the Sense HAT joystick.
25+
The first game, introduced in session 1. The objective is to reproduce the sequence of the arrows by moving the Sense HAT joystick. The game should increase in difficulty with each level by adding more steps to the sequence.
26+
27+
#### Extensions
28+
- Add more animations.
29+
- Play sound when the user guesses right, or loses game, for example (must wear headphones, or connect to a TV/monitor).
30+
31+
## Remote Message
32+
Remote message is a sample app to demo the Anvil service. The **remote_message.py** file uses the Anvil unplik service and acts as the server, allowing web clients to access the Pi through it's exposed methods, which are flagged with the @anvil.server.callable decorator. In order to run this demo, you must also clone the client web app [Remote App](https://anvil.works/build#clone:XVB2OIJR2V4DT5Y2=4SQ25RYVZG45OFIU7IXI6KA6)
33+
34+
Once cloned, you must enable the Uplink and get your own unique ID. Click on the Gear menu and choose Uplink:
35+
![Uplink Menu](https://anvil.works/learn/tutorials/img/raspberry-pi/uplink-gear-menu.png)
36+
37+
38+
Then Enable the Uplink to get your unique ID:
39+
![Uplink Enable](https://anvil.works/learn/tutorials/img/raspberry-pi/enable-uplink.png)
40+
41+
Now in your Raspberr Pi, with this repo cloned, edit the **remote_message.py** file to include this new ID:
42+
43+
```python
44+
@anvil.server.callable
45+
def show_messgage(message):
46+
sense.show_message(message)
47+
48+
anvil.server.connect("REPLACE_WITH_YOUR_OWN_UPLINK_ID")
49+
50+
```
1351

52+
Make sure to save and Run the app on the Raspberry Pi first before runnign the Anvil Web app.

Raspberry Pi Guide - CNC.pdf

1.14 MB
Binary file not shown.

basics.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Run the script in a terminal to test:
44
$ python3 basics.py
55
"""
6+
from sense_hat import SenseHat
67

78
#printing to the terminal:
89
print("Welcome to Python Basics!")
@@ -20,4 +21,7 @@
2021
# Your output should read: Malcom X was born in 1925 in Omaha Nebraska
2122

2223

23-
# TODO:Write a similar statement for a different notable person of your choice!
24+
# TODO:Write a similar statement for a different notable person of your choice!
25+
26+
27+
# TODO:Print it out to the Sense HAT!

examples/memory.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import time
33
import random
44

5-
65
sense = SenseHat()
76
sense.clear()
87

@@ -123,12 +122,11 @@ def next_level():
123122

124123
else:
125124
sense.set_pixels(left_arrow)
126-
127-
125+
128126
time.sleep(delay)
129127
sense.set_pixels(no_arrow)
130128

131-
#prevent two reating arrows from appearing as one.
129+
#prevent two repeating arrows from appearing as one.
132130
time.sleep(0.2)
133131

134132
player_turn = True
@@ -148,8 +146,7 @@ def next_level():
148146
# print(event.direction, event.action)
149147

150148
if event.action == "pressed" and event.direction != "middle":
151-
152-
#store in curent_pattern
149+
#store each event in player_pattern
153150
player_pattern.append(event.direction)
154151

155152
if event.action == "released" and event.direction == "middle":
@@ -160,8 +157,5 @@ def next_level():
160157
else:
161158
next_level()
162159

163-
164-
165-
166-
167-
160+
161+

memory.py

-69
This file was deleted.

memory_starter.py

+24-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,18 @@
1111
k = (0,0,0)
1212

1313

14-
left =[
14+
no_arrow = [
15+
w,w,w,w,w,w,w,w,
16+
w,w,w,w,w,w,w,w,
17+
w,w,w,w,w,w,w,w,
18+
w,w,w,w,w,w,w,w,
19+
w,w,w,w,w,w,w,w,
20+
w,w,w,w,w,w,w,w,
21+
w,w,w,w,w,w,w,w,
22+
w,w,w,w,w,w,w,w
23+
]
24+
25+
left_arrow =[
1526
w,w,w,w,w,w,w,w,
1627
w,w,r,w,w,w,w,w,
1728
w,r,r,w,w,w,w,w,
@@ -22,7 +33,7 @@
2233
w,w,w,w,w,w,w,w
2334
]
2435

25-
right =[
36+
right_arrow =[
2637
w,w,w,w,w,w,w,w,
2738
w,w,w,w,w,r,w,w,
2839
w,w,w,w,w,r,r,w,
@@ -33,7 +44,7 @@
3344
w,w,w,w,w,w,w,w
3445
]
3546

36-
down =[
47+
down_arrow =[
3748
w,w,w,w,w,w,w,w,
3849
w,w,w,r,w,w,w,w,
3950
w,w,w,r,w,w,w,w,
@@ -44,7 +55,7 @@
4455
w,w,w,r,w,w,w,w
4556
]
4657

47-
up =[
58+
up_arrow =[
4859
w,w,w,r,w,w,w,w,
4960
w,w,r,r,r,w,w,w,
5061
w,r,r,r,r,r,w,w,
@@ -56,7 +67,7 @@
5667
]
5768

5869
#list of arrows
59-
arrows = [up, down, left, right]
70+
arrows = ["up", "right", "down", "left"]
6071

6172

6273
#variable to hold level
@@ -66,6 +77,13 @@
6677
while True:
6778

6879
time.sleep(.3)
80+
<<<<<<< HEAD
6981
sense.set_pixels(up)
7082
time.sleep(.4)
71-
sense.set_pixels(down)
83+
sense.set_pixels(down)
84+
=======
85+
sense.set_pixels(up_arrow)
86+
time.sleep(.3)
87+
sense.set_pixels(down_arrow)
88+
89+
>>>>>>> bcce0f7ce7fbdca45ca322def6764df73acb9861

0 commit comments

Comments
 (0)