Go Down

Topic: Can I set pins 27, 28 to digital INPUT OUTPUT ? (Read 338 times) previous topic - next topic

ectar

Apr 07, 2013, 05:22 am Last Edit: Apr 07, 2013, 05:31 am by ectar Reason: 1
Having troubles settings 27, 28 to digital INPUT OUTPUT. I want to attach ultrasound sensor, but it just doesnt work.

Code: [Select]


int dypOutputPin = 28; // TRIG
int dypInputPin = 27;  // ECHO

....

void setup() {
 pinMode(dypOutputPin, OUTPUT);
 pinMode(dypInputPin, INPUT);
}

void loop() {

 //scan forward USS (ultrasonic sensor)
 digitalWrite(dypOutputPin, LOW);
 delayMicroseconds(2);
 digitalWrite(dypOutputPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(dypOutputPin, LOW);  
 // the distance is proportional to the time interval
 // between HIGH and LOW
 distance = pulseIn(dypInputPin, HIGH,50);
 cm = distance/58;  
 
 Serial.println(cm);
 delay(50);
}




Arduino UNO R3

jrdoner

As I understand it, you should either label those pins 18 and 19, or A1 and A0.  They are pins 27 and 28 on the microprocessor, but the Arduino terminology prevails.

James C4S

Why not name the pin variables "ECHO" and "TRIG"?  Wouldn't that make more sense than the variable names you are using now?

Which Arduino board are you using?
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

ectar

Never mind, it was not obvious that physical pins 28,27 are actually IDE pins 19, 18

Go Up