Go Down

Topic: Urgent - analog pin as digital input with flash (Read 325 times) previous topic - next topic

pmorrison

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 !!

Arnonh


TchnclFl

Code: [Select]
digitalRead(14, HIGH);

I have no idea what the outcome of that piece of code will be, but you certainly can't read something "HIGH".  You can either write it high, or read it.

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up