Hi~ This is my first project. I want to make a respite pillow for the students in our work space.
Respite in Chinese language is Xiao Qi, it has two meanings: one is have a little rest (小憩), another is a little bit mean(小器). I mention this because I thought my respite pillow is extremely suitable for the name of “Xiao Qi” pillow. People can have a nap on it, but after a certain time (10 mins as my final plan, but the test is only several seconds), it will wake you up! it won’t let you over sleep in the work space! A little bit mean to the tired people, right??
However, this is the code I made:
int fsrAnalogPin = 0;
int buzzer = 7;
int fsrReading;
int i=0;
void setup() {
Serial.begin(9600);
pinMode(buzzer, OUTPUT);
}
void loop(){
unsigned char k,j;
fsrReading=analogRead(fsrAnalogPin);
Serial.print(“Analog reading = “);
Serial.println(fsrReading);
if (fsrReading>=10){
i++;
if (i>=60){
for(k=0;k<100;k++){
digitalWrite(buzzer, HIGH);
delay(1);
digitalWrite(buzzer,LOW);
delay(1);
}
for(j=0;j<80;j++){
digitalWrite(buzzer,HIGH);
delay(3);
digitalWrite(buzzer,LOW);
delay(3);
}
}
}
else {
i=0;
digitalWrite(buzzer,LOW);
}
delay(100);
}
Hope everyone like it~~
Peggy