Hayden HarperAndrew MaykovichMichael Dawson
Published

IOT Project Group 16

Remote Controlling a laser through the use of multiple argons.

BeginnerFull instructions provided2 hours76
IOT Project Group 16

Things used in this project

Hardware components

Argon
Particle Argon
×3
LED (generic)
LED (generic)
×2
Rotary Encoder with Push-Button
Rotary Encoder with Push-Button
×1
Resistor 220 ohm
Resistor 220 ohm
×1
Through Hole Resistor, 4.7 kohm
Through Hole Resistor, 4.7 kohm
×1
Laser Emitter, Small Spot
Laser Emitter, Small Spot
×1
Gravity:Digital Push Button (Yellow)
DFRobot Gravity:Digital Push Button (Yellow)
×1
Breadboard Wire Kit
Digilent Breadboard Wire Kit
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Story

Read more

Schematics

Schematic of Rotary Encoder Argon Circuit

Schematic of Button Argon Circuit

Schematic of Laser Emit Argon Circuit

Code

First Argon

C/C++
Board 1 (encoder):
 
int outputB = D1;
int outputA = D0;
int counter = 0; 
 int aState;
int aLastState; 
 
void setup() { 
   pinMode (outputA, INPUT);
   pinMode (outputB, INPUT);
   Particle.subscribe("receivedledon", receivedledon, MY_DEVICES);
   Particle.subscribe("receivedledoff", receivedledoff, MY_DEVICES);
 
   Serial.begin (9600);
   
   aLastState = digitalRead(outputA);   
     
 } 
 
  void receivedledoff(const char *event, const char *data){
     
 }

 void receivedledon(const char *event, const char *data){
     
 }

 
 void loop() { 
   aState = digitalRead(outputA);
  
  
   if (aState != aLastState){     
    
     if (digitalRead(outputB) != aState) { 
       counter ++;
     } else {
       counter --;
     }
     Serial.print("Position: ");
     Serial.println(counter);
    
     if (counter == 2){
        Particle.publish("ledon", PRIVATE);
     }
     if (counter == -2){
         Particle.publish("ledoff", PRIVATE);
     }
     
   } 
   aLastState = aState;
}

Second Argon

C/C++
Board 2 (button):
 
int led1 = D0;
int button = D1;
bool ledstat;
int buttonstate;
int prevbutton;
void ledi(const char *event, const char *data){
    digitalWrite(led1, HIGH);
    ledstat = 1;
    delay(500);
    Particle.publish("receivedledon", PRIVATE);
    }
 
 
void ledo(const char *event, const char *data){
    digitalWrite(led1, LOW);
    ledstat = 0;
    Serial.print(ledstat);
    delay(500);
    Particle.publish("receivedledoff", PRIVATE);
}
 
void recievedlaser(const char *event, const char *data){
    
}
 
void setup(){
pinMode(led1, OUTPUT);
pinMode(button, INPUT_PULLDOWN);
Particle.subscribe("ledon", ledi, MY_DEVICES);
Particle.subscribe("ledoff", ledo, MY_DEVICES);
Particle.subscribe("receivedlaser", recievedlaser, MY_DEVICES);
ledstat = 0;
buttonstate = 0;

 
}
 
 
void loop(){
    prevbutton = buttonstate;
    Serial.print(buttonstate);
    buttonstate = digitalRead(button);
    if (prevbutton == 0 && buttonstate == 1 && ledstat == 1){
        Particle.publish("buttonpress", PRIVATE);
        digitalWrite(led1, LOW);
        delay(250);
        digitalWrite(led1, HIGH);
    }
    
 
}

Third Argon

C/C++
Board 3 (laser):
 
int laser = D0;
int led = D1;
 
void setup() {
pinMode(laser, OUTPUT);
pinMode(led, OUTPUT);
Particle.subscribe("buttonpress", laseron, MY_DEVICES);
digitalWrite(laser, LOW);
}
 
void laseron(const char *event, const char *data){
    delay(500);
    Particle.publish("receivedlaser", PRIVATE);
    digitalWrite(led, HIGH);
    digitalWrite(laser, HIGH);
    delay(1000);
    digitalWrite(laser, LOW);
    delay(1000);
    digitalWrite(laser, HIGH);
    delay(1000);
    digitalWrite(laser, LOW);
    delay(1000);
    digitalWrite(laser, HIGH);
    delay(1000);
    digitalWrite(laser, LOW);
    delay(1000);
    digitalWrite(laser, HIGH);
    delay(1000);
    digitalWrite(laser, LOW);
    delay(1000);
    digitalWrite(led, LOW);
}
 
 
 
 
 
 
 
void loop() {
 
}

Credits

Hayden Harper

Hayden Harper

1 project • 0 followers
Andrew Maykovich

Andrew Maykovich

1 project • 0 followers
Michael Dawson

Michael Dawson

1 project • 0 followers

Comments

Add projectSign up / Login