Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Bobby GaddyChris Sexton
Published

Iron Man Helmet

Added sensors to an iron man helmet to add cool features such as opening and closing the face shield as well as causing the eyes to glow.

BeginnerFull instructions provided4 hours670
Iron Man Helmet

Things used in this project

Hardware components

Argon
Particle Argon
×2
Photo resistor
Photo resistor
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
MG90s Servo
×2

Software apps and online services

ThingSpeak API
ThingSpeak API

Story

Read more

Schematics

Ultrasonic Sensor Wiring Diagram

Ultrasonic Sensor Wiring Diagram

Photoresistor Circuit

Photoresistor Circuit

Code

Ultrasonic Sensor Code

C/C++
#define HCSR04_PIN_TRIG D4
#define HCSR04_PIN_ECHO D5

Servo servo; // create servo object to control a servo
Servo servo2;
int  pos = 0;
int sound = 0;
long timeTaken;
long distance;
int onboardLed = 7;
int dischange = 0;

void setup() {
    
    Serial.begin(9600);
    pinMode(onboardLed, OUTPUT);
    pinMode(HCSR04_PIN_TRIG, OUTPUT);
    pinMode(HCSR04_PIN_ECHO, INPUT);
      servo.attach(A0);   // attaches the servo on pin 13 to the servo object
  servo2.attach(A1);
  Particle.subscribe("LED", LED);

}



void loop() {
    
    digitalWrite(HCSR04_PIN_TRIG, LOW);
    delayMicroseconds(2);
    digitalWrite(HCSR04_PIN_TRIG,HIGH);
    delayMicroseconds(10);
    digitalWrite(HCSR04_PIN_TRIG,LOW);
    timeTaken = pulseIn(HCSR04_PIN_ECHO,HIGH);
    distance = (timeTaken/2)/29.1;





if (distance <= 20) {                                   
    


    servo.write(0);
    servo2.write(180);
    

}

else {
    

    servo.write(130);
    servo2.write(50);

    }
    Particle.publish("distance", String(distance));
    delay(1000);

}

void LED(const char *event, const char *data) {
        digitalWrite(onboardLed, HIGH);
        delay(500);
        digitalWrite(onboardLed, LOW);
        delay(500);
}
        

Photoresistor Code

C/C++
//Setting Up Variables
int led1 = D6;
int led2 = D7;
int photoresistor = A0;
int analogvalue;


//Boot up code
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(photoresistor, OUTPUT);
Particle.variable("analogvalue", analogvalue);
Particle.subscribe("distance", LEDON);
}

//Code that will be repeated
void loop() {

    
}

void LEDON (const char *event, const char *data) {
    analogvalue = analogRead(photoresistor);
    delay(50);
    if (analogRead(photoresistor) < 1000)
    {

        digitalWrite(led1, HIGH);
        digitalWrite(led2, LOW);
        Particle.publish("LED", String(1), PUBLIC);
        delay(1000);
    }
    else
    {
        
        digitalWrite(led1, LOW);
        digitalWrite(led2, HIGH);
        Particle.publish("LED", String(0), PUBLIC);
delay(1000);
    }
}

Credits

Bobby Gaddy
1 project • 1 follower
Chris Sexton
1 project • 1 follower

Comments