Pages: [1]   Go Down
Author Topic: Urgent - analog pin as digital input with flash  (Read 311 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what code and libraries are you using?
Logged

B0100111001000011, USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1503
I'm confused.  Wait, maybe not..
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26285
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cross-posting:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1275034557/0#0
Logged

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

Pages: [1]   Go Up
Jump to: