I was trying to subtract 1 from the value of y and return the new value to y. Y being the number of available spaces. This is the entire code I turnd in, can I get an honest opinion. Ok, I figured out that serial out is raw data (duh, i said it was probably something stupid) and should have set up a quick and dirty web server, but resources run thin when your lab partners are tweetle dee and tweetle dum.
/*
Code written by Michael T Waugh
Jan - Feb 2011
Capstone Project
Professor Smellie
ITT Tech, Owings Mills, MD
The Isaac Asimov Intelligent Parking Facility
Arduino Uno board using Atmega328 chip
Sharp GP2YOD805Z0F Digital Distance Sensors (DDS) determine if parking space is in use
LED's indicate what parking spaces are in use
Sharp GP2YOD810Z0F DDS entrance & exit sensors account for cars in the garage but not yet parked
Serial out to display, digital pins 1 & 0 must be left open
Color indicates wire used, change at your discretion
LED anode to digital pin 5 parking space 1 Yellow
LED anode to digital pin 6 parking space 2 Blue
LED anode to digital pin 7 parking space 3 Purple
all LED cathodes to common ground Black
Sharp GP2YOD805Z0F DDS out pin to digital 8 parking space 1 Yellow
Sharp GP2YOD805Z0F DDS out pin to digital 9 parking space 2 Blue
Sharp GP2YOD805Z0F DDS out pin to digital 10 parking space 3 Purple
Sharp GP2YOD810Z0F DDS out pin to digital 13 entrance sensor Green
Sharp GP2YOD810Z0F DDS out pin to digital 12 exit sensor Yellow
all Sharp DDS Vin to +5V Red
all Sharp DDS gnd to common ground Black
*/
int ledspace1 = 5; // LED for parking space 1 set to digital pin 5
int ledspace2 = 6; // LED for parking space 2 set to digital pin 6
int ledspace3 = 7; // LED for parking space 3 set to digital pin 7
int sensorspace1 = 8; // sensor on parking space 1 set to digital pin 8
int sensorspace2 = 9; // sensor on parking space 2 set to digital pin 9
int sensorspace3 = 10; // sensor on parking space 3 set to digital pin 10
int valspace1 = 0; // variable to store the read value for parking space 1
int valspace2 = 0; // variable to store the read value for parking space 2
int valspace3 = 0; // variable to store the read value for parking space 3
int entrancesensor = 13; // sensor on entrance set to digital pin 13
int exitsensor = 12; // sensor on exit set to digital pin 12
int x = 3; // constant to store total number of spaces
int y = 3; // variable to store actual spaces
void setup()
{
Serial.begin(9600); // open the serial port at 9600 bps
pinMode(ledspace1, OUTPUT); // sets the digital pin 5 as output
pinMode(ledspace2, OUTPUT); // sets the digital pin 6 as output
pinMode(ledspace3, OUTPUT); // sets the digital pin 7 as output
pinMode(sensorspace1, INPUT); // sets the digital pin 8 as input
pinMode(sensorspace2, INPUT); // sets the digital pin 9 as input
pinMode(sensorspace3, INPUT); // sets the digital pin 10 as input
pinMode(exitsensor, INPUT); // sets the digital pin 12 as input
pinMode(entrancesensor, INPUT); // sets the digital pin 13 as input
Serial.println("Isaac Asimov Intelligent Parking Facility" );// displays Isaac etc...
Serial.println("Spaces available:"); // prints the available spaces
Serial.print(y);
}
void loop()
{
if (digitalRead(entrancesensor)); // if the entrance sensor reads
else (y = y--); Serial.print(y); // then subtract 1 from the total spaces & print
delay(1000); // wait 1 second
valspace1 = digitalRead(sensorspace1); // read parking sensor 1
digitalWrite(ledspace1, valspace1); // sets the LED to parking sensor 1 value
valspace2 = digitalRead(sensorspace2); // read parking sensor 2
digitalWrite(ledspace2, valspace2); // sets the LED to parking sensor 2 value
valspace3 = digitalRead(sensorspace3); // read parking sensor 3
digitalWrite(ledspace3, valspace3); // sets the LED to parking sensor 3 value
if (digitalRead(exitsensor)); // if the exit sensor reads
else (y = y++); Serial.print(y); // then add 1 to the total spaces & print
delay(1000); // wait 1 second
}