Fat Cat Alarm

Prevent Opal, the fat cat, from stealing the other cats' food

Made by kaylageer

Context: A counter mat with embedded weight sensors would be programmed to trigger a blinking red light and a noise maker (daddy suggested that it be able to shock the cat too…). If Opal, who weighs twice as much as Marble or Gravel, is on the pad and is blocking the light from a photoresistor embedded in Marble's food bowl. If one of the lighter cats is on the pad and is blocking the light, or if Opal is sitting on the pad and not eating, a green indicator light will be on.

Created: January 27th, 2015

0

Components:

(1) Spark core

(1) Breadboard

(1) USB micro B cable

(10) Jumper wires

(1) Red LED

(1) Green LED

(1) Photoresistor

(1) Force-sensitive resistor

(2) 1kO resistors

(2) 10kO resistor

0
//force resistor code based on tutorial https://docs.google.com/document/d/1KfkRd1UqBzrUTvw8Td6STyXqi8mmj_4G6rC4CB0OF_g/edit#heading=h.cwfvi2lnk1xg
//photoresistor code based on tutorial https://docs.google.com/document/d/1cpnWEScjDwxmhv_xTfwn8HPi3nZpJ2gO7ZOY5ChN1Q4/edit#heading=h.cwfvi2lnk1xg

int fsrPin = A0;
int photoPin = A2;
int grnPin = D2;
int redPin = D0;
int photoReading = 0;
int fsrReading = 0;
int ledBrightness1 = 0;
int ledBrightness2 = 0;

void setup()
{
pinMode(redPin, OUTPUT);
pinMode(grnPin, OUTPUT);
Spark.variable("light", &photoReading, INT);
Spark.variable("force", &fsrReading, INT);
}

void loop()
{
digitalWrite(redPin, LOW);
digitalWrite(grnPin, LOW);
photoReading = analogRead(photoPin);
fsrReading = analogRead(fsrPin);

ledBrightness1 = map(photoReading, 0, 4095, 0, 255);
ledBrightness2 = map(fsrReading, 0, 4095, 0, 255);

if(ledBrightness1 < 150 && ledBrightness2 >= 150){
analogWrite(redPin, ledBrightness1);
delay(250);
analogWrite(redPin, LOW);
delay(250);
analogWrite(redPin, ledBrightness1);
delay(250);
analogWrite(redPin, LOW);
delay(250);
analogWrite(redPin, ledBrightness1);
delay(250);
analogWrite(redPin, LOW);
delay(250);
}
else if(ledBrightness1 >= 150 || ledBrightness2 < 150){
digitalWrite(grnPin, ledBrightness1);
}
delay(100);

}
Click to Expand
0
0

*Make sure everything is grounded.

**If the code has issues, try resetting the spark core and closing/reopening the file.

x
Share this Project


About

Context: A counter mat with embedded weight sensors would be programmed to trigger a blinking red light and a noise maker (daddy suggested that it be able to shock the cat too…). If Opal, who weighs twice as much as Marble or Gravel, is on the pad and is blocking the light from a photoresistor embedded in Marble's food bowl. If one of the lighter cats is on the pad and is blocking the light, or if Opal is sitting on the pad and not eating, a green indicator light will be on.