Details of this Paper

I wanna fix the code problems

Description

solution


Question

Hello Please I wanna fix the code problems as it does not run through arduino propaply;Here is the CODE;/***************************************************************/ /* */ /* Garage Controller Range v2.0 */ /* */ /***************************************************************/ #include #define SF(x) String(F(x)) #define CF(x) String(F(x)).c_str() #define RANGE_MIN 35 #define RANGE_MAX 39 #define RANGE_1 49 #define RANGE_2 64 #define RANGE_3 84 #define RANGE_4 200 int iPinRed1 = 3, int iPinRed2 = 4, int iPinRed3 = 5, int iPinRed4 = 6, int iPinGreen1 = 7, int iPinRed5 = 8, int iPinRange = 9, /***************************************************************/ /* Function: setup */ /***************************************************************/ void setup() { Serial.begin(9600), Serial.println(SF("setup()")), pinMode(iPinRed1, OUTPUT), pinMode(iPinRed2, OUTPUT), pinMode(iPinRed3, OUTPUT), pinMode(iPinRed4, OUTPUT), pinMode(iPinGreen1, OUTPUT), pinMode(iPinRed5, OUTPUT), pinMode(iPinRange, OUTPUT), } /***************************************************************/ /* Function: loop */ /***************************************************************/ void loop() { long lDuration = 0, lCM = 0, // 2 Microsecond Clear + 5 Microsecond Pulse pinMode(iPinRange, OUTPUT), digitalWrite(iPinRange, LOW), delayMicroseconds(2), digitalWrite(iPinRange, HIGH), delayMicroseconds(5), digitalWrite(iPinRange, LOW), // Get Return Pulse pinMode(iPinRange, INPUT), lDuration = pulseIn(iPinRange, HIGH), lCM = ConvertMSToCM(lDuration), Serial.println("Distance: " + String(lCM) + " cm"), // Too Close if (lCM = RANGE_MIN & lCM = RANGE_MAX & lCM = RANGE_1 & lCM = RANGE_2 & lCM = RANGE_3 & lCM = RANGE_4) { digitalWrite(iPinRed1, LOW), digitalWrite(iPinRed2, LOW), digitalWrite(iPinRed3, LOW), digitalWrite(iPinRed4, LOW), digitalWrite(iPinGreen1, LOW), digitalWrite(iPinRed5, LOW), } else { digitalWrite(iPinRed1, LOW), digitalWrite(iPinRed2, LOW), digitalWrite(iPinRed3, LOW), digitalWrite(iPinRed4, LOW), digitalWrite(iPinGreen1, LOW), digitalWrite(iPinRed5, LOW), } delay(50), } /***************************************************************/ /* Function: ConvertMSToCM */ /***************************************************************/ long ConvertMSToCM(long lMicroSeconds) { // The speed of sound is 340 m/s or 29 microseconds per centimeter. // The ping travels out and back, so to find the distance of the // object we take half of the distance travelled. - Arduino Site return lMicroSeconds / 29 / 2, } Here is the link to the project: http://blog.mikejmcguire.com/2014/04/20/using-an-arduino-as-a-garage-gar-parking-sensor/

 

Paper#63867 | Written in 18-Jul-2015

Price : $22
SiteLock