We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpElectronics,  Serial Library › Newbie question about DigitalRead()
Page Index Toggle Pages: 1
Newbie question about DigitalRead() (Read 1311 times)
Newbie question about DigitalRead()
Feb 16th, 2010, 5:56pm
 
Hello all, this is my first post to this forum so I will apologize up front for my super-newbie question.  I just bought my first Arduino board and I am trying to get it to listen to an LED that I have flashing on a seperate breadboard.  The breadboard is hooked up to a Basic Stamp microcontroller.  It is a simple circuit that switches a pin on the Basic Stamp from HIGH to LOW every 1.5 seconds.  I took a jumper and wired it from the same row as the positive end of the LED that is flashing and inserted it into pin 13 on the digital side of the Arduino board.  I am using the Processing program for the Arduino below to try and detect when the LED is on and off but am sure I am doing something very wrong.  Any help would be greatly appreciated.

import processing.serial.*;
import cc.arduino.*;

Arduino arduino;
int ledPin = 13;
int val;
void setup()
{
 //size(300,300);
 println(Arduino.list());
 arduino = new Arduino(this, Arduino.list()[3], 57600);
}

void draw()
{
// background(off);
//  stroke(on);
 for (int i = 0; i < 6; i++) {
   if (arduino.digitalRead(ledPin) == Arduino.HIGH){
     fill(153);
     println("grey");
 }    else {
    noFill();
    println("no fill");
 }
  // rect(420 - i * 30, 30, 20, 20);
 }
 
 }

Re: Newbie question about DigitalRead()
Reply #1 - Feb 20th, 2010, 11:25pm
 
Have you loaded firmata onto the Arduino? If not, your Processing sketch will be talking to deaf hardware.

This may help:
http://www.arduino.cc/playground/Interfacing/Processing
Page Index Toggle Pages: 1