LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to Arduino

Solved!
Go to solution

as far as the \ code I am just going with what the other link in my first post suggested

 

"To further explore communication with the Arduino, build a sketch that listens at the Arduino for a serial message or use the Dimmer example which wants you to send a single character followed by a carriage control to change the LED."

 

but I do see you point

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 11 of 31
(5,268 Views)

Yes.  Why are you sending 3 characters of 2 5 5 and then the carriage return?   Earlier in your message thread, you said "send a single character followed by a carriage control to change the LED".

 

At that time, it wasn't clear what the "single character" meant, but it certainly didn't mean sending 3 characters.

 

Also, why are you sending a carriage return?  Since the basic code you posted is only reading the serial port and putting it into a one byte variable, it either doesn't care that a carriage return is send, or worse, the carriage return is screwing up the read.

 

What you need to do is take your value (that is a U8 integer) and typecast it to string, then wire that to the VISA write.

 

 

 

0 Kudos
Message 12 of 31
(5,263 Views)

ok I type casted the Visa Write to string and nothing is happening I think I have the electricals right now I belive the LabVIEW code is correct and the arduino code is correct bevause I have looked through the forum and they all say it worked for them, so I don't know what I am doing wrong, but than again I am a bit new to using VISA

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 13 of 31
(5,250 Views)

well the LED turns on but I don't think that is due to my LabVIEW program because when I send it a new value it does not dim I am using this code in my arduino and everything seems to be connected properly, but still not able to write to my arduino

 

Here is the code:

 

/*
  Analog input, analog output, serial output
 
 Reads an analog input pin, maps the result to a range from 0 to 255
 and uses the result to set the pulsewidth modulation (PWM) of an output pin.
 Also prints the results to the serial monitor.
 
 The circuit:
 * potentiometer connected to analog pin 0.
   Center pin of the potentiometer goes to the analog pin.
   side pins of the potentiometer go to +5V and ground
 * LED connected from digital pin 9 to ground
 
 created 29 Dec. 2008
 by Tom Igoe
 
 */

// These constants won't change.  They're used to give names
// to the pins used:
const int analogInPin = 0;  // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to

int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);            
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 255);  
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);           

  // print the results to the serial monitor:
  Serial.print("sensor = " );                       
  Serial.print(sensorValue);      
  Serial.print("\t output = ");      
  Serial.println(outputValue);   

  // wait 10 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(10);                     
}

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 14 of 31
(5,239 Views)
Solution
Accepted by topic author Harold_Timmis

Now you are going off into another direction by worrying about an analog input pin.

 

You need to make sure you can get one thing working first.  You say you don't think you have the serial communication working.  Do what I said which is create a basic program that runs on the board and reads its serial port then turns around and writes the data right back.  Then if you get your LV program to write and read, you'll know whether serial is working.  I'd recommend making your wait statement a little larger, perhaps 250 to 500 milliseconds.

 

If you're not sure the LED portion is working right, then make a basic program to run on the board that does nothing but blink the LED.  Write a 255 to the port, wait a second, write a 0 to the port, wait a second, Loop.

 

Once you know that both of these different features are working, then it should be a simple matter to get both aspects to work together in one program.

0 Kudos
Message 15 of 31
(5,224 Views)

I have been able to read in the data just not write to the arduino

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 16 of 31
(5,217 Views)

oc so I am using serial.read and serial.write and it is worlking perfectly I am able to change the number from 0 to 255 awesome thank you guys so much i just don't know who to give the solution to

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 17 of 31
(5,210 Views)

Turning on and off a LED never felt better

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 18 of 31
(5,199 Views)

for future Engineers/Scientists who want to use the Arduino and LabVIEW and want an example here you go:

 

 

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Message 19 of 31
(5,195 Views)

Hi,

Could you please post pictures or 7.1 version of your vis?

Thx

0 Kudos
Message 20 of 31
(5,067 Views)