dave1956 Posted August 19, 2021 Report Share Posted August 19, 2021 i can NOT get downloaded code to verify on computer for arduino nano, HELP Quote Link to comment Share on other sites More sharing options...
HarryA Posted August 20, 2021 Report Share Posted August 20, 2021 Can you copy this code and paste it into the IDE and get it to compile? Be sure to select nano in the IDE tools->board = "Arduino Nano". This is for an ultrasonic device but for testing you do not need the device: #define trigPin 9 #define echoPin 10 long duration; int distance; long firstoff; int distancefirst; void setup() { Serial.begin(9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); delay(1000); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); firstoff = pulseIn(echoPin, HIGH); distancefirst = firstoff*0.034/2; // cm digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance= duration*0.034/2; // cm //distance = duration * 0.0133 / 2; // in Serial.println(distance); delay(1000); Serial.println(distancefirst); if (distance <= distancefirst - 5) { tone(3, 500, 500); delay(500); tone(3, 800, 500); delay(500); delay(50); } } It is the first project from: https://create.arduino.cc/projecthub/projects/tags/nano Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.