LabVIEW Vietnam

cancel
Showing results for 
Search instead for 
Did you mean: 

viết code arduino sang labview

em có đoạn code viết bằng arduino.đọc cảm biến tiệm cận E3F-DS30C4 và xuất ra module relay .mới học bên labview nên không rành lắm về lệnh so sánh bên labiew.mọi người có thể giúp em đc không ạ..

TheLoser_1-1589712416693.png

file labview ở dưới 

code arduino:

int CB = 8; // Chan tin hieu Cam bien -> Chân số 8 Arduino (digital)
int Relay = 6; // Led 5V đấu chân dương vào chân số 6 Arduino (digital)
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
pinMode(CB,INPUT); //Setup ngõ vào
pinMode(Relay,OUTPUT); // Setup ngõ ra
}

void loop() {
// put your main code here, to run repeatedly:
int val = digitalRead(CB); // Đọc tín hiệu Cảm biến (digital)

//So sánh tín hiệu trả về
if(val == 1){
digitalWrite(Relay,0);
Serial.println(" not found ");
}
else{
digitalWrite(Relay,1);
Serial.println(" Co tin hieu ");
}
}

 

 

 

 

0 Kudos
Message 1 of 2
(3,020 Views)

phuc324_0-1590200990831.png

Bạn nên so sánh kí tự như mình nó dễ hơn 

if(Serial.available()>0)
{
x=Serial.read();

if(x=='a')
{
digitalWrite(den,LOW);
delay(100);
}
if(x=='b')
{
digitalWrite(den,HIGH);
delay(100);

}

0 Kudos
Message 2 of 2
(2,978 Views)