Daniel SedanoTristan MansfieldJolisa Brown
Published

Lockin' It Down

Cure your phone addiction and increase your productivity with this state-of-the-art phone cage, a jail cell for your cell phone!

IntermediateFull instructions provided526
Lockin' It Down

Things used in this project

Hardware components

Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
EK-TM4C123GXL TM4C Tiva LaunchPad
Texas Instruments EK-TM4C123GXL TM4C Tiva LaunchPad
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Energia
Texas Instruments Energia

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Cage Body

This is the body of the Phone Cage

Cage Cover

This is the cover of the Phone Cage

Cage Top

This is the very top part of the Phone Cage's body

Pin

This is the pin that functions as a lock.

Schematics

Phone Cage Circuits

The wiring of the different components of the phone Cage, with the Launchpad represented by a black rectangle.

Code

Phone Cage Code

C/C++
This is the Energia program that runs the phone cage.
#include <Servo.h>
#include <SevSeg.h>

//Initializing pins as output/input
int redpin = 30;
int bluepin = 40;
int potpin = 18;
int servopin = 10;
const int buttonpin = 7   ; //Need Digital input


int val = 0;
int valset;
int buttonstate = 0; //To have 0/1 for if pushed or not
int pos;

Servo lock; //Declares a servo object
SevSeg display; //Declares a display object

//This whole section for the sevseg display
int digit1=6;
int digit2=5;
int digit3=28;
int digit4=29;

//This whole section for the sevseg display
int seg1=19;
int seg2=17;
int seg3=3;
int seg4=15;
int seg5=38;
int seg6=14;
int seg7=31;
int seg8=33;

void setup() {
Serial.begin(9600);

lock.attach(servopin); // Initializing the pin for the Servo

pinMode(redpin, OUTPUT); // board led
pinMode(bluepin, OUTPUT);
pinMode(potpin, INPUT); // potpin
pinMode(buttonpin, INPUT_PULLUP); // button pin

byte numDigits = 4;
byte digitPins[] = {digit1, digit2, digit3, digit4};
byte segmentPins[] = {seg1, seg2, seg3, seg4, seg5, seg6, seg7, seg8};
bool resistorsOnSegments = false; // 'false' means resistors are on digit pins
byte hardwareConfig = COMMON_ANODE; // See README.md for options
bool updateWithDelays = true; // Default 'false' is Recommended
bool leadingZeros = false; // Use 'true' if you'd like to keep the leading zeros
bool disableDecPoint = true;
display.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments,
  updateWithDelays, leadingZeros, disableDecPoint); //also need to have refreshDisplay() and disable dp
display.setBrightness(100);

}

void loop() {
  // put your main code here, to run repeatedly: 

  val = analogRead(potpin); // The ptentiometer must constantly be read in order to knowtime settings
  val = map(val, 0, 4095, 0, 30);
  buttonstate = digitalRead(buttonpin);

  
if (val != 0) {
//    display.refreshDisplay();
    val = analogRead(potpin);
    val = map(val, 0, 4095, 0, 30); // 0 to 30 seconds from pot    
    Serial.println(val);
    display.setNumber(val);
    display.refreshDisplay();
//    buttonstate = digitalRead(buttonpin);

    if (buttonstate == 1){  // It has been pressed
      display.refreshDisplay();
      valset=val;
      digitalWrite(redpin, HIGH);
      digitalWrite(bluepin, HIGH);
      display.refreshDisplay();
      
      //engage motor
      for(pos = 90; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
      {                                  // in steps of 1 degree 
        lock.write(pos);              // tell servo to go to position in variable 'pos' 
        delay(10);                       // waits 15ms for the servo to reach the position 
      } 
      display.refreshDisplay();
      
      while(valset>0){
//        display.setNumber(valset);
//        display.refreshDisplay();
        display.refreshDisplay();
        Serial.println(valset);
        display.refreshDisplay();
        display.setNumber(valset);
        display.refreshDisplay();
        //To replace delay()
        for(unsigned long debut = millis(); millis() - debut < 1000;) {
          display.refreshDisplay();
        }

        valset -= 1;
        display.refreshDisplay();
        if(valset==1){
          display.refreshDisplay();
          for(pos = 180; pos > 90; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    lock.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(10);                       // waits 15ms for the servo to reach the position 
  } 
  display.refreshDisplay();
        }
      }
    



         
      
      digitalWrite(redpin, LOW);
      digitalWrite(bluepin,LOW);



      
  display.refreshDisplay();
    }    }  }

  
  

  

Credits

Daniel Sedano

Daniel Sedano

1 project • 0 followers
Tristan Mansfield

Tristan Mansfield

1 project • 0 followers
Jolisa Brown

Jolisa Brown

1 project • 0 followers

Comments