I have used Arduino for some time now but have never encountered this kind of error before.
My code gets compiled fast, but then just says Uploading... forever. Same story even for other programs like Blink.
Here is the code:
const int trigPin = 4;
const int echoPin = 2;
const int trigPin2 = 6;
char incomingByte;
char val, val2;
const int echoPin2 = 7;
void setup() {
// initialize serial communication:
Serial.begin(9600);
}
void loop()
{
pinMode(trigPin, OUTPUT);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
pinMode(trigPin2, OUTPUT);
digitalWrite(trigPin2, LOW);
delayMicroseconds(2);
digitalWrite(trigPin2, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin2, LOW);
// Read the signal from the sensor: a HIGH pulse whose
// duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(echoPin, INPUT);
pinMode(echoPin2, INPUT);
val = digitalRead(echoPin);
val2 = digitalRead(echoPin2);
if (val && val2 == HIGH)
{
Serial.println("Obstruction!");
}
if (Serial.available() > 0) { // if the data came
incomingByte = Serial.read();
}
// read byte
if(incomingByte == '0') {
digitalWrite(trigPin, LOW);
digitalWrite(trigPin2, LOW);
Serial.println("The system is OFF."); // print message
}}
The message I got is: avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
Any help would be appreciated.