1 /* Arduino Projects for Dummies
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
9 * Use this code to test and calibrate your Hall Effect sensors
10 * without posting a tweet
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
21 Serial.begin(9600); // Open a serial connection to display the data
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
30 Serial.println(exitReading); // Print the exit
31 delay(500); // Wait a moment, so we can read what's been printed