Components and supplies
Battery Holder, 18650 x 2
Toggle Switch, (On)-Off-(On)
Regulator Step Down LM2596
SG90 Micro-servo motor
Arduino MKR WiFi 1010
MKR RGB Shield
Tools and machines
Multitool, Screwdriver
Plier, Long Nose
3D Printer (generic)
Project description
Code
Code Otto
arduino
1#include <ArduinoGraphics.h> // Arduino_MKRRGB depends on ArduinoGraphics 2#include <Arduino_MKRRGB.h> 3#include <Servo.h> 4 5Servo bracoE, pernaE, peE, bracoD, pernaD, peD; 6 7byte y = 0; 8 9void setup() { 10 // initialize the display 11 MATRIX.begin(); 12 13 // set the brightness, supported values are 0 - 255 14 MATRIX.brightness(10); 15 16 bracoE.attach(A1); //Brao esquerdo 170 alto, 80 baixo 17 pernaE.attach(A2); //Perna esquerda 170 frente, 80 meio, 0 tras 18 peE.attach(A3); //P esquerdo 170 cima, 80 plano, 10 ponta de p 19 bracoD.attach(A4); //Brao direito 170 baixo, 80 alto 20 pernaD.attach(A5); //Perna direita 170 tras, 80 meio, 10 frente 21 peD.attach(A6); ////P direito 0 cima, 80 plano, 160 ponta de p 22 23 posInicial(); 24 delay(2000); 25 26} 27void loop() { 28 29 for (byte x = 0; x < 5; x++) { 30 // set one pixel GREEN, using the stroke and point methods 31 MATRIX.beginDraw(); 32 MATRIX.clear(); 33 MATRIX.stroke(0, 0, 255); 34 //=======OLHO ABERTO====================== 35 //Olho esquerdo 36 MATRIX.point(2, 1); 37 MATRIX.point(1, 2); 38 MATRIX.point(2, 2); 39 MATRIX.point(3, 2); 40 MATRIX.point(0, 3); 41 MATRIX.point(1, 3); 42 MATRIX.point(2, 3); 43 MATRIX.point(3, 3); 44 MATRIX.point(1, 4); 45 MATRIX.point(2, 4); 46 MATRIX.point(3, 4); 47 MATRIX.point(2, 5); 48 //Olho direito 49 MATRIX.point(8, 1); 50 MATRIX.point(7, 2); 51 MATRIX.point(8, 2); 52 MATRIX.point(9, 2); 53 MATRIX.point(7, 3); 54 MATRIX.point(8, 3); 55 MATRIX.point(9, 3); 56 MATRIX.point(10, 3); 57 MATRIX.point(7, 4); 58 MATRIX.point(8, 4); 59 MATRIX.point(9, 4); 60 MATRIX.point(8, 5); 61 MATRIX.endDraw(); 62 63 delay(2000); 64 65 MATRIX.clear(); 66 67 //=======OLHO NORMAL====================== 68 //Olho esquerdo 69 MATRIX.point(1, 2); 70 MATRIX.point(2, 2); 71 MATRIX.point(3, 2); 72 MATRIX.point(0, 3); 73 MATRIX.point(1, 3); 74 MATRIX.point(2, 3); 75 MATRIX.point(3, 3); 76 MATRIX.point(1, 4); 77 MATRIX.point(2, 4); 78 MATRIX.point(3, 4); 79 //Olho direito 80 MATRIX.point(7, 2); 81 MATRIX.point(8, 2); 82 MATRIX.point(9, 2); 83 MATRIX.point(7, 3); 84 MATRIX.point(8, 3); 85 MATRIX.point(9, 3); 86 MATRIX.point(10, 3); 87 MATRIX.point(7, 4); 88 MATRIX.point(8, 4); 89 MATRIX.point(9, 4); 90 MATRIX.endDraw(); 91 92 delay(30); 93 94 MATRIX.clear(); 95 96 //=======OLHO FECHANDO====================== 97 //Olho esquerdo 98 MATRIX.point(0, 3); 99 MATRIX.point(1, 3); 100 MATRIX.point(2, 3); 101 MATRIX.point(3, 3); 102 MATRIX.point(1, 4); 103 MATRIX.point(2, 4); 104 MATRIX.point(3, 4); 105 //Olho direito 106 MATRIX.point(7, 3); 107 MATRIX.point(8, 3); 108 MATRIX.point(9, 3); 109 MATRIX.point(10, 3); 110 MATRIX.point(7, 4); 111 MATRIX.point(8, 4); 112 MATRIX.point(9, 4); 113 MATRIX.endDraw(); 114 115 delay(30); 116 117 MATRIX.clear(); 118 119 //=======OLHO FECHADO====================== 120 //Olho esquerdo 121 MATRIX.point(1, 3); 122 MATRIX.point(2, 3); 123 MATRIX.point(3, 3); 124 MATRIX.point(2, 4); 125 //Olho direito 126 MATRIX.point(7, 3); 127 MATRIX.point(8, 3); 128 MATRIX.point(9, 3); 129 MATRIX.point(8, 4); 130 MATRIX.endDraw(); 131 132 delay(30); 133 134 MATRIX.clear(); 135 136 //=======OLHO ESPREMIDO====================== 137 //Olho esquerdo 138 MATRIX.point(1, 3); 139 MATRIX.point(2, 3); 140 MATRIX.point(3, 3); 141 //Olho direito 142 MATRIX.point(7, 3); 143 MATRIX.point(8, 3); 144 MATRIX.point(9, 3); 145 MATRIX.endDraw(); 146 147 delay(130); 148 // clear the display 149 MATRIX.beginDraw(); 150 MATRIX.noFill(); 151 MATRIX.noStroke(); 152 MATRIX.clear(); 153 MATRIX.endDraw(); 154 } 155 y=1; 156 while (y > 0) { 157 passoEsquerdo(60, 60, 50, 1000); 158 passoDireito(110, 120, 100, 1000); 159 if (y == 4) { 160 y = 0; 161 posInicial(); 162 delay(2000); 163 //=======OLHO RAIVA====================== 164 MATRIX.beginDraw(); 165 MATRIX.clear(); 166 MATRIX.stroke(255, 0, 0); 167 //Olho esquerdo 168 MATRIX.point(0, 2); 169 MATRIX.point(1, 2); 170 MATRIX.point(2, 2); 171 MATRIX.point(3, 2); 172 MATRIX.point(0, 3); 173 MATRIX.point(1, 3); 174 MATRIX.point(2, 3); 175 MATRIX.point(0, 4); 176 MATRIX.point(1, 4); 177 //Olho direito 178 MATRIX.point(7, 2); 179 MATRIX.point(8, 2); 180 MATRIX.point(9, 2); 181 MATRIX.point(10, 2); 182 MATRIX.point(8, 3); 183 MATRIX.point(9, 3); 184 MATRIX.point(10, 3); 185 MATRIX.point(9, 4); 186 MATRIX.point(10, 4); 187 MATRIX.endDraw(); 188 malhando(); 189 } 190 } 191} 192 193void posInicial() { 194 bracoE.write(80); 195 pernaE.write(72); 196 peE.write(80); 197 bracoD.write(170); 198 pernaD.write(80); 199 peD.write(80); 200} 201 202int passoEsquerdo(int levantarCorpo, int enpurrarPeOposto, int girarCorpo, int tempo) { 203 peD.write(levantarCorpo); 204 peE.write(enpurrarPeOposto); 205 delay(tempo); 206 pernaD.write(girarCorpo); 207 delay(tempo); 208 posInicial(); 209 delay(tempo); 210} 211 212int passoDireito(int levantarCorpo, int enpurrarPeOposto, int girarCorpo, int tempo) { 213 peD.write(levantarCorpo); 214 peE.write(enpurrarPeOposto); 215 delay(tempo); 216 pernaD.write(girarCorpo); 217 delay(tempo); 218 posInicial(); 219 delay(tempo); 220 y++; 221} 222 223void malhando() { 224 bracoE.write(170); 225 bracoD.write(80); 226 delay(1000); 227 bracoE.write(80); 228 bracoD.write(170); 229 delay(1000); 230 bracoE.write(170); 231 bracoD.write(80); 232 peE.write(20); 233 peD.write(150); 234 delay(2000); 235 bracoE.write(170); 236 bracoD.write(80); 237 peE.write(80); 238 peD.write(80); 239 delay(2000); 240 bracoE.write(80); 241 bracoD.write(170); 242 peE.write(20); 243 peD.write(150); 244 delay(2000); 245 bracoE.write(170); 246 bracoD.write(80); 247 peE.write(80); 248 peD.write(80); 249 delay(2000); 250 bracoE.write(80); 251 bracoD.write(170); 252 peE.write(20); 253 peD.write(150); 254 delay(2000); 255 bracoE.write(170); 256 bracoD.write(80); 257 peE.write(80); 258 peD.write(80); 259 delay(2000); 260 bracoE.write(80); 261 bracoD.write(170); 262 peE.write(20); 263 peD.write(150); 264 delay(2000); 265 bracoE.write(170); 266 bracoD.write(80); 267 peE.write(80); 268 peD.write(80); 269 delay(2000); 270 bracoE.write(80); 271 bracoD.write(170); 272 peE.write(20); 273 peD.write(150); 274 delay(2000); 275 bracoE.write(170); 276 bracoD.write(80); 277 peE.write(80); 278 peD.write(80); 279 delay(2000); 280 posInicial(); 281 MATRIX.clear(); 282 delay(2000); 283 284} 285
Downloadable files
Circuit Otto
Circuit Otto
Circuit Otto
Circuit Otto
Comments
Only logged in users can leave comments