Urgent - analog pin as digital input with flash

Hi all,

I want to use analog analog pin as digital input pin in as3 as i ran out of digital pins.

I can use it in arduino IDE by writing,


pinMode(14, INPUT); digitalRead(14, HIGH);


but how can i use it in as3? It is not working with flash. I used the following code in as3,


import net.eriksjodin.arduino.Arduino; import net.eriksjodin.arduino.events.ArduinoEvent;

var a:Arduino; a = new Arduino("127.0.0.1", 5331); a.addEventListener(Event.CONNECT , onSocketConnect); a.addEventListener(ArduinoEvent.FIRMWARE_VERSION , onReceiveFirmwareVersion); a.addEventListener(ArduinoEvent.DIGITAL_DATA, onReceiveDigitalData);

function onSocketConnect(e:Event):void { a.requestFirmwareVersion(); }

function onReceiveFirmwareVersion(e:ArduinoEvent):void { a.setPinMode(2,Arduino.INPUT); a.setPinMode(14,Arduino.INPUT);

}

function onReceiveDigitalData(e:ArduinoEvent):void { trace(e.pin , e.value); }


As you can see in the code I am also using digital pin 2 and it works with the digital pin 2 but its not working with digital pin 14.

I want to analog pin 0 (digital 14) to detect motion form a digital PIR sensor (high and low) without expander. I think I am missing something in flash code.

Waiting for your quick replies. I am in real urgent at this moment.

Thank you all in advance.

Cheers !!

digitalRead(14, HIGH);

That code is nonsensical. Please fix your question.

That code is nonsensical.

No, it isn't. The analog pins can be used as digital pins. When they are, the pin numbers are 14 through 19, on the Duemilanove.

Yes, it really is nonsensical. Read it again.

I read that as a problem with using pin 14, completely missing the fact that the function is not being used correctly. Something about a plank...

OH my,

yes it is nonsensical !! Sorry guys.. just too stressed out !! Anyway, so its, pinMode(14, INPUT); digitalWrite(14, HIGH);

But I fixed my problem with writing analog value to my if statement and its working cool now :)

Thanks guys. Cheers !!

Damn.. NO actually its not nonsensical actually !!

Check this out, http://www.arduino.cc/en/Tutorial/AnalogInputPins

Thanks. Cheers !!

Really it is rubbish - read it really carefully, and maybe take a look at the prototypes in "wiring.h"

Trust me, I'm god.

AWOL’s right - there is nothing on the page you linked that refutes it.

Just in case you’re still puzzled, here’s the offending line:

digitalRead(14, HIGH);

(I’m a god too)

Alright gods.. well i don't know.. m not a programmer.. but I solved it by putting analog values in my if statements and its working fine :)

Cheers !!