View Single Post
  #22   Spotlight this post!  
Unread 03-04-2011, 07:05
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 689
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: Arduino and LabVIEW

(Sorry, I went home and slept a bit.) Here's the Arduino sketch:
Code:
int ledPin = 13; // LED connected to digital pin 13
int inPin = 7;   // pwm white wire connected to digital pin 7
int val = 0;     // variable to store the read value

void setup()
{
  pinMode(ledPin, OUTPUT);    // sets the digital pin 13 as output
  pinMode(inPin, INPUT);      // sets the digital pin 7 as input
  Serial.begin(9600);           //Added this, seems to allow the prints to print
}

void loop()
{
  val = digitalRead(inPin);   // read the input pin
  digitalWrite(ledPin, val);    // sets the LED to the button's value
  Serial.println(val);            // print out the 1 or 0
  delay(500);                    // Added 1/2 second delay just to slow down the prints
}
I took it from Arduino's DigitalRead() page. I wasn't going to get fancy until I got something that made sense.

On the LabVIEW side there is code that if (one of 4) buttons are pressed, send a True/False to DIO Out Set (WPI_DigitalOutputSetValue.vi). I hold the button down to test, not momentarily. Currently (with the delay) the print sends "1100000111000011000001100" with or without the button presses, and there is no pattern to the length of the 1 or 0 groups. Without the delay it was all 1s. I also used the built-in LED on 13 to see if it's on or off.

RoboMaster: I have the book version of that video (that's how I got my first Arduino). I'm not ashamed to say I'm not electrical-minded, but I know enough to keep me out of too much trouble. For this project originally I used the button setup to control the Arduino switching the LEDs. I've wondered about that resistor. This would be a simple test: Put the wire on a breadboard, split it with a resistor to ground, and a wire to Arduino's pin 7.

I did understand David's answer (I think I did; hanging around teens I get that a lot), and I was answering more of a programming mode than electrically.

WizenedEE: Maybe in the "robot world" the DIO ports aren't left floating, but when the wire is jumping into "Arduino world", would it need it's own de-floater resistor? I'm guessing at this.

I do have a sensors/electrical mentor; he probably knows every wire on the robot on a first-name basis. He can test the wires to make sure they are what they ought to be.

Sigh. Electricity was so much simpler when I grew up, when power went from + to - and not both ways.
Reply With Quote