Diannamertz (talk | contribs) No edit summary |
mNo edit summary |
||
Line 10: | Line 10: | ||
<br> | <br> | ||
Above image source: Flickr user iDecrease | Above image source: Flickr user iDecrease | ||
===Setup=== | |||
http://farm4.static.flickr.com/3254/2507585112_60cc338bfb_m.jpg | http://farm4.static.flickr.com/3254/2507585112_60cc338bfb_m.jpg | ||
Above image source: http://code.google.com/p/sserial2mobile/ | Above image source: http://code.google.com/p/sserial2mobile/ | ||
[http://code.google.com/p/sserial2mobile/ <b>Arduino to Mobile Code Example</b>] | [http://code.google.com/p/sserial2mobile/ <b>Arduino to Mobile Code Example</b>] | ||
<syntaxhighlight lang="cpp"> | |||
SSerial2Mobile phone = SSerial2Mobile(2,3); | |||
phone.sendTxt("+017655555555","Remember to buy more coffee!"); | |||
phone.sendEmail("ilovecoffee@gmail.com", "Remember to buy more coffee!"); | |||
Serial.print("Batt: "); | |||
Serial.print(phone.batt()); | |||
Serial.println("%"); | |||
Serial.print("RSSI: "); | |||
Serial.println(phone.rssi()); | |||
</syntaxhighlight> | |||
[[../code#III Potentiometer .28Arduino.29|Photo Resistor Code Example (from class)]] | |||
<syntaxhighlight lang="cpp"> | |||
// specify the pin numbers we are going to use: | |||
int ledPin = 13; | |||
int potiPin = 3; | |||
// create a variable to hold the value from the poti: | |||
int potiValue; | |||
void setup(){ | |||
// set the pin mode of the led pin to act as an output: | |||
pinMode(ledPin,OUTPUT); | |||
// establish a serial connection: | |||
Serial.begin(9600); | |||
} | |||
void loop(){ | |||
// read the current value of the poti pin | |||
// and store it in the variable potiValue: | |||
potiValue = analogRead(potiPin); | |||
// if the value is over a certain threshold | |||
// (here it's 511 or the middle of the range), | |||
// turn the LED on, otherwise turn it off: | |||
if(potiValue > 511){ | |||
digitalWrite(ledPin,HIGH); | |||
}else{ | |||
digitalWrite(ledPin,LOW); | |||
} | |||
// in oder to send the poti value as one byte (0-255) | |||
// we have to scale it from the original range (0 - 1023): | |||
int scaledVal = map(potiValue,0,1023,0,255); | |||
// send the scaled value via the serial port as a byte: | |||
Serial.print(scaledVal,BYTE); | |||
// wait a little bit to not overload the serial buffer: | |||
delay(50); | |||
} | |||
</syntaxhighlight> | |||
===Equipment=== | |||
* [http://www.sparkfun.com/products/9607 Cellular Shield] | |||
* SIM card | |||
* Antenna | |||
* Arduino | |||
* Photoresistor | |||
* Coffee can | |||
* Depleting coffee grounds | |||
[http://www.sparkfun.com/products/9607 Cellular | |||
SIM card | |||
Antenna | |||
Arduino | |||
Photoresistor | |||
Coffee can | |||
Depleting coffee grounds | |||
<b>Tasks:</b | <b>Tasks:</b> | ||
<ul> | <ul> | ||
<li>Acquire sim card</li> | <li>Acquire sim card</li> |
Revision as of 20:26, 15 December 2011
In my WG, my flatmates and I take turns buying the coffee grounds. Sometimes this becomes confusing, as there are three of us, and the person who is next in line to buy coffee is not necessarily aware that the coffee supply is low.
I'd like to develop a system that ensures that our WG is always supplied with enough coffee. Using Arduino and a photoresistor, I propose to install a sensor inside the coffee ground that will send a reminder SMS to the next person in line as soon as the coffee levels are low.
File:Coffee03.jpg
File:Coffee04.jpg
Above image source: Flickr user iDecrease
Setup
Above image source: http://code.google.com/p/sserial2mobile/
Arduino to Mobile Code Example
SSerial2Mobile phone = SSerial2Mobile(2,3);
phone.sendTxt("+017655555555","Remember to buy more coffee!");
phone.sendEmail("ilovecoffee@gmail.com", "Remember to buy more coffee!");
Serial.print("Batt: ");
Serial.print(phone.batt());
Serial.println("%");
Serial.print("RSSI: ");
Serial.println(phone.rssi());
Photo Resistor Code Example (from class)
// specify the pin numbers we are going to use:
int ledPin = 13;
int potiPin = 3;
// create a variable to hold the value from the poti:
int potiValue;
void setup(){
// set the pin mode of the led pin to act as an output:
pinMode(ledPin,OUTPUT);
// establish a serial connection:
Serial.begin(9600);
}
void loop(){
// read the current value of the poti pin
// and store it in the variable potiValue:
potiValue = analogRead(potiPin);
// if the value is over a certain threshold
// (here it's 511 or the middle of the range),
// turn the LED on, otherwise turn it off:
if(potiValue > 511){
digitalWrite(ledPin,HIGH);
}else{
digitalWrite(ledPin,LOW);
}
// in oder to send the poti value as one byte (0-255)
// we have to scale it from the original range (0 - 1023):
int scaledVal = map(potiValue,0,1023,0,255);
// send the scaled value via the serial port as a byte:
Serial.print(scaledVal,BYTE);
// wait a little bit to not overload the serial buffer:
delay(50);
}
Equipment
- Cellular Shield
- SIM card
- Antenna
- Arduino
- Photoresistor
- Coffee can
- Depleting coffee grounds
Tasks:
- Acquire sim card
- Alter or substitute coffee can so the connection from Arduino to photoresistor is possible.
- Alter code so that the phone numbers alternate between roommates.