Neue Pin in Arduino einbinden

Hallo,

Gerne möchte ich mit Andruino meine AVR Platine Steuern.
Dazu habe paar Pin welche muss ich verwenden, aber sind nicht bei ATMEGA2560 - Arduino Aufgelistet.
Meine Frage betreff z.B. PortD.4;PortD.5 und PortD.6.
Gibt eine direkte Befehl z.B. int MyPin = PD.5 ?

Danke

Roman
PS Ich habe gerade mit Arduino angefangen!

uint8_t mypin = PIND & _BV(PD5);

Mit einem original arduino mega board ist das allerdings nutzlos, da nicht alle pins verdrahtet sind.

http://arduino.cc/en/Hacking/PinMapping2560 bzw
http://arduino.cc/en/uploads/Main/arduino-mega2560_R3-schematic.pdf

Grüße Uwe

Danke für Information,

Werde ich sofort Testen.

Ich benutze eine Platine mit AT2560 welche will ich zu RepRap Drucker "Zwingen" versuche. Hat jedoch nicht alle Pins nach außen aufgeführt, dazu hat aber paar andere (Nicht bekante für Arduino) auf Steckleiste.

Grüße

Roman

Hallo,
Keine Fehler Meldung aber Pin statisch hat eine "Low", klappert nicht wie LED Pin
meine Testcode:

int ledPin = 13; // LED connected to digital pin 13
uint8_t testpin = PIND & _BV(PD5);

// The setup() method runs once, when the sketch starts

void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(testpin, OUTPUT);
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
digitalWrite(testpin, HIGH); // set the PD5 on
delay(500); // wait for a 0.5 second
digitalWrite(ledPin, LOW); // set the LED off
digitalWrite(testpin, LOW); // set the PD5 on
delay(100); // wait for a 0.1 second
digitalWrite(ledPin, HIGH); // set the LED on
digitalWrite(testpin, HIGH); // set the PD5 on
delay(100); // wait for a 0.1 second
digitalWrite(ledPin, LOW); // set the LED off
digitalWrite(testpin, LOW); // set the PD5 on
delay(100); // wait for a 0.1 second

}

Was habe ich falsch getan?

Danke und Grüße

Ah. Wir muessen tiefer gehen...

http://www.arduino.cc/playground/Code/BitMath

Um den status eines pins auszulesen oder zu aendern braucht es:

data direction register (DDRx), port register (PORTx) und pin register (PINx).

Beispiele:

A)

DDRD |= _BV(PD5); // pin PD5 als ausgang
PORTD |= _BV(PD5); // pin PD5 HIGH
delay(1000);
PORTD &= ~_BV(PD5); // pin PD5 LOW

B)

DDRD &= ~_BV(PD5); // pin PD5 als eingang
if( PIND & _BV(PD5) ) {
  Serial.println("PD5 HIGH");
}
if( !(PIND & _BV(PD5)) ) {
  Serial.println("PD5 LOW");
}

Hallo!

Funktioniert.

Leider habe ich vorher probiert mit :
uint8_t testpin = PIND & _BV(PD5); // Pin Definieren
pinMode(testpin, OUTPUT); // Pin als output schalten (DDRX)
digitalWrite(testpin, HIGH); // Pin High (oder Low) Setzen

was teoretisch solte gleiche funktion haben wie:

DDRD |= _BV(PD5); // pin PD5 als ausgang
PORTD |= _BV(PD5); // pin PD5 HIGH

aber hat nicht funktioniert. Glaube ich Pin Definition ist daneben gegangen oder pinmode bzw. digital write funktion.

Mit Direkte Anweisungen funktioniert sehr Gut!.

Danke für Deine Information.