Pages: [1]   Go Down
Author Topic: Can I set pins 27, 28 to digital INPUT OUTPUT ?  (Read 300 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Having troubles settings 27, 28 to digital INPUT OUTPUT. I want to attach ultrasound sensor, but it just doesnt work.

Code:

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
« Last Edit: April 06, 2013, 10:31:15 pm by ectar » Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 112
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: