]> git.piffa.net Git - arduino/blob - books/pdummies/APFD_Chapter11_Tweeting_PetDoor_Test/APFD_Chapter11_Tweeting_PetDoor_Test.ino
first commit
[arduino] / books / pdummies / APFD_Chapter11_Tweeting_PetDoor_Test / APFD_Chapter11_Tweeting_PetDoor_Test.ino
1 /* Arduino Projects for Dummies
2  * by Brock Craft 
3  *
4  * Chapter 11: Building a Tweeting Pet Door
5  * A system that uses hall effect sensors to 
6  * detect the movement of a pet flap and then
7  * posts a message to your (or your pet's) twitter account
8  *
9  * Use this code to test and calibrate your Hall Effect sensors
10  * without posting a tweet
11  *
12  * v0.1 30.04.2013
13 */
14
15 const int entryPin = A0;   // Define the input pin for entry sensor
16 const int exitPin = A1;    // Define the input pin for the exit sensor
17 int entryReading = 0;  // Define variable to store the entry value
18 int exitReading = 0;   // Define variable to store the exit value
19
20 void setup() {
21   Serial.begin(9600);  // Open a serial connection to display the data
22 }
23
24 void loop() {
25   entryReading = analogRead(entryPin); // Read the value from entry sensor
26   exitReading = analogRead(exitPin);   // Read the value from exit sensor
27   Serial.print("Sensor values: ");   
28   Serial.print(entryReading); // Print the entry sensor value
29   Serial.print(", "); 
30   Serial.println(exitReading); // Print the exit
31   delay(500);  // Wait a moment, so we can read what's been printed
32 }