-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlesson3.html
More file actions
213 lines (191 loc) · 10.6 KB
/
lesson3.html
File metadata and controls
213 lines (191 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!--
lesson3.html
Authors: Javier Laveaga, William Goldman, Izzy Morales
Date: July 31, 2024
Version: 1.0
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Lessons Placemat</title>
<!-- MAKE SURE YOU KEEP THE PYSCRIPT IMPORT UP TO DATE-->
<script type="module" src="https://pyscript.net/releases/2025.2.1/core.js"></script>
<link rel="stylesheet" href="https://pyscript.net/releases/2025.2.1/core.css">
<script src="script.js"></script>
<link rel="icon" type="image/png" href="images/favicon-32x32.png">
<link rel="stylesheet" href="./style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <!--For save button-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <!--For download exception icon-->
</head>
<body id = "lesson3">
<script type="mpy-editor" src="./main.py" config="./pyscript.toml" setup></script>
<header>
<nav class="headbar">
<a href="index.html" id="lesson1-link" >Lesson 1</a>
<a href="lesson2.html" id="lesson2-link">Lesson 2</a>
<a href="lesson3.html" id ="lesson3-link" class="active">Lesson 3</a>
<a href="lesson4.html" id="lesson4-link">Lesson 4</a>
<a href="lesson5.html" id="lesson5-link">Lesson 5</a>
<a href="lesson6.html" id="lesson6-link">Lesson 6</a>
</nav>
</header>
<div class="container">
<div class="section title-section">
<h1>AI Puppy Lesson 3: Tricks</h1>
<p style="font-size:20px">Code and train your puppy to do at least 2 tricks based on what a sensor reads!</p>
</div>
<div class="two-boxes-container">
<div class="yellow-box">
<h2>Machine Learning Type</h2>
<p style="font-size:18px">
<a href="https://www.geeksforgeeks.org/k-nearest-neighbours/" class="special-link">1D K-Nearest Neighbor</a>
</p>
</div>
<div class="yellow-box">
<h2>Tools Used</h2>
<p style="font-size:18px">One sensor (any), motors, & starter code</p>
</div>
</div>
<div class="section go-sections">
<h2>Example Ideas</h2>
<p>Build a puppy that can be petted!</p>
<img class="puppyPicture" src="nobgimages/aipuppy4_360-removebg-preview.png" alt="Puppy 4">
<img class="puppyPicture" src="nobgimages/aipuppy5_480-removebg-preview.png" alt="Puppy 5">
<img class="puppyPicture" src="nobgimages/aipuppy2_360-removebg-preview.png" alt="Puppy 2">
</div>
<div class="section go-sections">
<h2>Tips & Troubleshooting</h2>
<div class="container3">
<div class="threeCol">
<div class="column">
<p class="title"><span style="font-weight: bold;">READ</span> through the code before adding your own code!</p>
<br>
<p class="title">Check for typos</p>
</div>
<div class="column">
<p class="title" style="font-weight: bold;">Use any of the following sensor functions:</p>
<code style="font-family: 'Courier New', Courier, monospace; font-size: 16px;">ai.get_distance<br>ai.get_force<br>ai.get_light</code>
<p class="title" style="font-weight: bold;">Example code below!</p>
</div>
<div class="column">
<p class="title">You do not need to use functions from CEEO_AI to code tricks!</p>
<br>
<p class="title">Make sure your ports are correct</p>
</div>
</div>
<div class="code-block">
<span class="blue-text">def</span><span class="red-text"> cool_trick</span>():
motor.run_for_degrees(legL, 90, 720)
motor.stop()
<span class="blue-text">def</span><span class="red-text"> better_trick</span>():
light_matrix.show_image(light_matrix.IMAGE_PACMAN)
light_matrix.clear()
<span class="gray-text"># For help with coding LEGO motors or hub, go to LEGO's education SPIKE™ webpage!</span>
ai.add_data(<span class="green-text">'cool trick'</span>, ai.get_light(c_sensor))
</div>
</div>
</div>
<div class="container2">
<div class="header">
<div class="topDisplay">
<button class="button1 active" id="connect-spike">Connect</button>
<!--FOR RUN BUTTON-->
<!-- partial:index.partial.html -->
<div class="button-row">
<button class="button | button--toggle button--play disabled" id="custom-run-button" data-editor-id="MPcode" disabled> <i class="ph-play | gg-play-button"></i>
<i class="ph-pause | gg-play-stop"></i>
</button>
</div>
<!--button class="button1" id="custom-run-button" data-editor-id="MPcode">Run</button-->
<!--button class="button1" id="custom-run-button" >Run</button-->
<!--button class="button1" id="save_button" >Save</button-->
<button id="save_button" class="button1">
<i class="fa fa-save" ></i>
</button>
<div class="status-container">
<div id="sensor-info" class="sensor-info-container"></div>
<div class="progress-container" id="progressDiv">
<progress id="progress" value="0" max="100"></progress>
<span class="progress-text" id="progress-percent">0%</span>
</div>
</div>
</div>
</div>
<div id="overlay" class="overlay">
<div class="modal">
<p>
Do you want to save on SPIKE? <br>
<span class="subtitle"> (gives option to save locally first) </span>
</p>
<button id= "Yes-btn" class="btn-yes" >Yes</button>
<button id = "No-btn" class="btn-no" >No</button>
</div>
</div>
<div class="flexBox">
<br>
<div class="box left-box">
<textarea id='gitpath' >https://raw.githubusercontent.com/iliketocode2/AI-Puppy-UI/main/Lessons/Main_Lesson3.py https://raw.githubusercontent.com/iliketocode2/AI-Puppy-UI/main/Lessons/Lesson3_demo.py https://raw.githubusercontent.com/iliketocode2/AI-Puppy-UI/main/Lessons/CEEO_AI.py </textarea>
<!--<label for="files">Choose a file:</label> -->
<div class="filesDiv">
<select name="files" id="files" class="files">
</select>
</div>
<div class="gifFrame"><img id="gif"></div>
<div class="horizontal-buttons">
<input type="file" id="fileRead" style="display: none;"> <!--Hide actual file selector. FileRead id important for JS function-->
<button class="button1" type="button" id="chooseFileButton">
<i class="fa fa-upload"></i>
</button>
<!--button class="button1" id="download-code">Download Code</button-->
<button id="download-code" class="button1">
<i class="fa fa-download"></i>
</button>
<button class="button1" id="sensor_readings">Sensors</button>
</div>
<div class="portInstructions" id="portInfo">
<h3>Port Assignments</h3>
<div class="wrap">
<p>Choose your own!</p>
</div>
</div>
</div>
<div class="right-container">
<div class="box right-box" id="hide_on_1_and_2">
<div class ="terminalFrame" id="terminalFrameId">Pyscript Editor
<script id="MPcode" type="mpy-editor" env="ble" class="mpy-editor-container"></script>
</div>
</div>
<div class="slider">...</div>
<div class="box right-box" id="resizeBox">
<div class="tab">
<button class="tablinks active" id="customTerminalButton" style="color: black;">Terminal</button>
<button class="tablinks" id="defaultTerminalButton" style="color: black;">Debug</button>
</div>
<div id="debug" class="tabcontent">
<div id="repl"></div>
</div>
<div id="terminal" class="tabcontent">
<div id="terminalMessages">
<div id="customTerminalMessage">Please connect to a SPIKE™ Prime to begin programming.<br><br></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="section go-sections">
<h2>Extended Thinking</h2>
<p>Can you add more actions and train your puppy to distinguish between them? Can you use a different sensor to train your puppy?</p>
<img src="nobgimages/th-removebg-preview (1).png" alt="Your brain if you think about this" width="100px" height="auto">
</div>
<footer>
<p style="text-align: center;">
<img style="height:50px;width:auto;"src="images/tags2.png" alt="intermediate ai animals">
</p>
<p>----------------------------------------------------------------------- ©2024. All rights reserved.Tufts.edu.com -----------------------------------------------------------------------</p>
</footer>
</div>
</body>
</html>