code:
[const int pingPin = 7;
void setup() {
Serial.begin(9600);
}
void loop() {
long duration, inches, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
long microsecondsToInches(long microseconds) {
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2;
}]
error message:Arduino: 1.6.12 (Mac OS X), Board: "Arduino Nano, ATmega328"
Sketch uses 2,642 bytes (8%) of program storage space. Maximum is 30,720 bytes.
Global variables use 194 bytes (9%) of dynamic memory, leaving 1,854 bytes for local variables. Maximum is 2,048 bytes.
/Users/svteacher/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino6/bin/avrdude -C/Users/svteacher/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino6/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.wchusbserial620 -b57600 -D -Uflash:w:/var/folders/_h/cw2_jv2j0kb8m4shtlxb48900000gq/T/arduino_build_337768/qweert.ino.hex:i
avrdude: Version 6.3, compiled on Sep 12 2016 at 17:22:25
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/Users/svteacher/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino6/etc/avrdude.conf"
User configuration file is "/Users/svteacher/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/cu.wchusbserial620
Using Programmer : arduino
Overriding Baud Rate : 57600
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
avrdude done. Thank you.
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
its on the nano