Fab Academy 2013

Final project development (in progress).

My final project is a cat friendly bench. This bench has an interactive tube inside. When the cat goes inside the tube aN ultrasonic sensor pick the cat up and some leds inside the tube will light up.

Final documentation of the CAT FRIENDLY BENCH at the

Final Project html page.

final

Main parts of the project:

Computer Controlled Machining

Cat friendly bench, link to all the documentation here.

Composite

Resina: ENDUR RESOLTECH 1045N... 3 hours time before resine cures. Link to all the documentation here (in progress)

Electronics design and production

All the process documentation can be found here.

Fabduino ATmega168A 16MHz

handmadeledstripeHandmade Led Stripe with 74HC595 8 bit shift register

Electronics design and production files

Programming: ultrasonic sensor + handmade led stripe

all
 
/*
27 mayo 2013 Fab Academy Fab Lab Leon 

This code is a mix between: 
* HC-SR04 Ping distance sensor]
 VCC to arduino 5v GND to arduino GND
 Echo to Arduino pin 13 Trig to Arduino pin 12
 More info at: http://goo.gl/kJ8Gl
 
* An example of the 74HC595 8 bit shift register that has been found here http://bildr.org/2011/02/74hc595/
 */

//ultrasonic sensor pins
#define trigPin 5
#define echoPin 4

//74HC595 Pins that connects to Arduino
int SER_Pin = 8;   //pin 14 on the 75HC595
int RCLK_Pin = 9;  //pin 12 on the 75HC595
int SRCLK_Pin = 10; //pin 11 on the 75HC595

//How many of the shift registers - change this
 #define number_of_74hc595s 1 
 
 //do not touch
 #define numOfRegisterPins number_of_74hc595s * 8 
 boolean registers[numOfRegisterPins];


void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  
   pinMode(SER_Pin, OUTPUT);
  pinMode(RCLK_Pin, OUTPUT);
  pinMode(SRCLK_Pin, OUTPUT);


  //reset all register pins 74hc595
  clearRegisters();
  writeRegisters();
}


//set all register pins to LOW
void clearRegisters(){
  for(int i = numOfRegisterPins - 1; i >=  0; i--){
     registers[i] = LOW;
  }
} 

//Set and display registers
//Only call AFTER all values are set how you would like (slow otherwise)
void writeRegisters(){

  digitalWrite(RCLK_Pin, LOW);

  for(int i = numOfRegisterPins - 1; i >=  0; i--){
    digitalWrite(SRCLK_Pin, LOW);

    int val = registers[i];

    digitalWrite(SER_Pin, val);
    digitalWrite(SRCLK_Pin, HIGH);

  }
  digitalWrite(RCLK_Pin, HIGH);

}

//set an individual pin HIGH or LOW
void setRegisterPin(int index, int value){
  registers[index] = value;
}

void loop() {
  int duration, distance;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  if (distance <20 ) {
    // when the cat gets into the house/tube leds start lighting
    setRegisterPin(1, HIGH);
  setRegisterPin(2, LOW);
  setRegisterPin(3, LOW);
  setRegisterPin(4, LOW);
  setRegisterPin(5, LOW);
  setRegisterPin(6, LOW);
  setRegisterPin(7, LOW);
  writeRegisters(); 
  delay (100); 
  
  setRegisterPin(1, LOW);
  setRegisterPin(2,  HIGH);
  setRegisterPin(3, LOW);
  setRegisterPin(4, LOW);
  setRegisterPin(5, LOW);
  setRegisterPin(6, LOW);
  setRegisterPin(7, LOW);
  writeRegisters(); 
   delay (100); 
  setRegisterPin(1, LOW);
  setRegisterPin(2, LOW);
  setRegisterPin(3, HIGH);
  setRegisterPin(4, LOW);
  setRegisterPin(5, LOW);
  setRegisterPin(6, LOW);
  setRegisterPin(7, LOW);
   writeRegisters(); 
   delay (100);
   
     setRegisterPin(1, LOW);
  setRegisterPin(2, LOW);
  setRegisterPin(3, LOW);
  setRegisterPin(4, HIGH);
  setRegisterPin(5, LOW);
  setRegisterPin(6, LOW);
  setRegisterPin(7, LOW);
   writeRegisters(); 
   delay (100);
   
    setRegisterPin(1, LOW);
  setRegisterPin(2, LOW);
  setRegisterPin(3, LOW);
  setRegisterPin(4, LOW);
  setRegisterPin(5, HIGH);
  setRegisterPin(6, LOW);
  setRegisterPin(7, LOW);
   writeRegisters(); 
   delay (100);
    setRegisterPin(1, LOW);
  setRegisterPin(2, LOW);
  setRegisterPin(3, LOW);
  setRegisterPin(4, LOW);
  setRegisterPin(5, LOW);
  setRegisterPin(6, HIGH);
  setRegisterPin(7, LOW);
   writeRegisters(); 
   delay (100);
   
      setRegisterPin(1, LOW);
  setRegisterPin(2, LOW);
  setRegisterPin(3, LOW);
  setRegisterPin(4, LOW);
  setRegisterPin(5, LOW);
  setRegisterPin(6, LOW);
  setRegisterPin(7, HIGH);
   writeRegisters(); 
   delay (100);
  
   setRegisterPin(1, LOW);
  setRegisterPin(2, LOW);
  setRegisterPin(3, LOW);
  setRegisterPin(4, LOW);
  setRegisterPin(5, LOW);
  setRegisterPin(6, LOW);
  setRegisterPin(7, LOW);
  
   writeRegisters(); 
   delay (100);
  }
  
  
  if (distance >= 200 || distance <= 0){
    Serial.println("Out of range");
  }
  else {
    Serial.print(distance);
    Serial.println(" cm");
    
  delay(500);
}
}