This project was a hard one to finish in time, from 3d filiment running out to a snow storm preventing parts from coming in. I was able to stray away from my physical piece as I proposed in my proposal as a back up plan if anything went wrong, and it did. So my project now is a tinkercad piece with servos, LEDs, a buzzer and "voice control" (and a self desctruct).
The first couple of days of this project was at home 3d printing the helmet and making a list of conponents required, luckily for the acuation of the helmet I had everything needed, but of course that wouldnt be enough. Once everything was printed the process of glueing was a tedious process and is right now on the 24th being finished. The tinkercad project was all done on friday in class when the relization hit that I was going to be late on my due date.
I learned alot from this project as it was my first project with a due date and had a plan for. I had Lex help me with code syntax due to I kept forgetting the difrence from java script to python and C (or whatever arduino uses) The 3d printing was one main factor of my project being delayed and aswell as that, electronics are expensive, most of the stuff I wanted to do needed a Rasberry Pi which I do not have the funds for, and as well as that shippinng takes forever. My main take aways is that projects take time and with propper planning you can do anything, I had my backup plan that I didnt belive I needed but here we are with my project being online. Some things I do need to improve on is my time manegment.
Link:
https://www.tinkercad.com/things/iBhLmZ55k4o-powerfullahdi/editelsharecode=SJbnw379DLnetrjZrmQYGK7OAlAjPD9LRqQYilROExg
#include <Servo.h>
Servo servoTop;
Servo servoBottom;
int buttonState = 0;
int buttonStateNew;
int buttonStateOld = 1;
int buttonPin = 2;
const int buzzer = 3;
#define LEDR 4
#define LEDGB 5
int cap = 6;
int bottom_closed = 107;
int top_closed = 167;
int bottom_open = 20;
int top_open = 20;
void setup() {
Serial.begin(9600);
pinMode(buttonPin, INPUT);
pinMode(buzzer, OUTPUT);
pinMode(LEDR, OUTPUT);
pinMode(LEDGB, OUTPUT);
pinMode(cap, OUTPUT);
servoTop.attach(9);
servoBottom.attach(10);
}
void loop() {
//Toggle Button
buttonStateNew= digitalRead(buttonPin);
if(buttonStateOld == 0 && buttonStateNew == 1){
if (buttonState==0){
Serial.println(buttonState);
buttonState = 1;
faceUp();
} else {
Serial.println(buttonState);
buttonState = 0;
faceDown();
}
}
buttonStateOld=buttonStateNew;
//Voice recognition
String message;
while(Serial.available()) {
message = Serial.readString();
message.toLowerCase();
if (message.equals("open")) {
faceUp();
} else if (message.equals("close")) {
faceDown();
} else if (message.equals("attack")) {
attack();
} else if (message.equals("destruct")) {
selfDestruct();
}
}
}
void faceUp () {
tone(buzzer, 100, 1000);
servoTop.write(20);
servoBottom.write(20);
analogWrite(LEDR, 125);
analogWrite(LEDGB, 255);
}
void faceDown () {
tone(buzzer, 800, 1000);
servoTop.write(107);
servoBottom.write(167);
analogWrite(LEDR, 125);
analogWrite(LEDGB, 255);
}
void attack () {
analogWrite(LEDR, 255);
analogWrite(LEDGB, 0);
Serial.println("attack engadgeed");
tone(buzzer, 500);
}
void selfDestruct () {
tone(buzzer, 1000);
delay(500);
noTone(buzzer);
delay(500);
digitalWrite(cap, HIGH);
Serial.println("Commenced");
}